text: ﻿(function () {
      'use strict';
  
      angular
          .module('app')
          .factory('UserService', Service);
  
      function Service($http, $q) {
          var service = {};
  
          service.GetCurrent = GetCurrent;
          service.GetAll = GetAll;
          service.GetById = GetById;
          service.GetByUsername = GetByUsername;
          service.Create = Create;
          service.Update = Update;
          service.Delete = Delete;
          service.postData = postData;
          service.getstatusData = getstatusData;
         /* service.postPhoto = postPhoto;*/
  
          return service;
  
          function GetCurrent() {
              return $http.get('/api/users/current').then(handleSuccess, handleError);
          }
  
          function GetAll() {
              return $http.get('/api/users').then(handleSuccess, handleError);
          }
  
          function GetById(_id) {
              return $http.get('/api/users/' + _id).then(handleSuccess, handleError);
          }
  
          function GetByUsername(username) {
              return $http.get('/api/users/' + username).then(handleSuccess, handleError);
          }
  
          function Create(user) {
              return $http.post('/api/users', user).then(handleSuccess, handleError);
          }
  
          function Update(user) {
              return $http.put('/api/users/' + user._id, user).then(handleSuccess, handleError);
          }
  
          function Delete(_id) {
              return $http.delete('/api/users/' + _id).then(handleSuccess, handleError);
          }
          
          function postData(data) {
              return $http.post('/api/users/postData', data).then(handleSuccess, handleError);
          }
          
          function getstatusData() {
              return $http.get('/api/users/getstatusData').then(handleSuccess, handleError);
          }
  
          /*function postPhoto(data) {
              // console.log(data); return;
              var fd = new FormData();
                 fd.append('file', data);
              var uploadUrl = '/api/users/postPhoto';
              // console.log(uploadUrl); return;
                return $http.post(uploadUrl, fd, {
                    transformRequest: angular.identity,
                    headers: {'Content-Type': undefined}
                 }).then(handleSuccess, handleError);
          }*/
          // private functions
  
          function handleSuccess(res) {
              return res.data;
          }
  
          function handleError(res) {
              return $q.reject(res.data);
          }
      }
  
  })();
  