Exemple #1
0
        public UserViewModel UpdateUser([FromBody] UserViewModel aUser)
        {
            var aAuthUser = VerifyUser(HttpContext.User);

            if (aAuthUser.ClinicUserId == aUser.UserId)
            {
                var    aClinicUser = _OMSDContext.ClinicUser.Find(aUser.UserId);
                byte[] passwordHash, passwordSalt;
                CreatePasswordHash(aUser.Password, out passwordHash, out passwordSalt);
                aClinicUser.Email        = aUser.Email;
                aClinicUser.Firstname    = aUser.UserFirstName;
                aClinicUser.Lastname     = aUser.UserLastName;
                aClinicUser.Password     = Convert.ToBase64String(passwordHash);
                aClinicUser.Pin          = Convert.ToBase64String(passwordSalt);
                aClinicUser.Address1     = aUser.Address;
                aClinicUser.City         = aUser.City;
                aClinicUser.Province     = Province.Find(aUser.Province).Id;
                aClinicUser.PhoneNumber  = aUser.PhoneNumber;
                aClinicUser.PostalCode   = aUser.PostCode;
                aClinicUser.ModifiedDate = DateTime.Now;

                using (_OMSDContext)
                {
/*                    _OMSDContext.ClinicUser.Update(aClinicUser);
 *                  _OMSDContext.SaveChanges();*/
                }
            }
            return(aUser);
        }
Exemple #2
0
        public UserViewModel GetUser(int id)
        {
            var aAuthUser = VerifyUser(HttpContext.User);

            ClinicUser aClinicUser = null;

            //if(aAuthUser.ClinicUserType == UserType.AdminUser.Id)
            if (true)
            {
                aClinicUser = _OMSDContext.ClinicUser.Find(id);
            }

            if (aClinicUser != null)
            {
                return(new UserViewModel
                {
                    UserId = aClinicUser.ClinicUserId,
                    Email = aClinicUser.Email,
                    UserFirstName = aClinicUser.Firstname,
                    UserLastName = aClinicUser.Lastname,
                    Token = "",
                    Password = "",
                    Message = "find user",
                    Address = aClinicUser.Address1,
                    Province = Province.Find(aClinicUser.Province).Name,
                    City = aClinicUser.City,
                    PostCode = aClinicUser.PostalCode,
                    PhoneNumber = aClinicUser.PhoneNumber,
                });
            }
            else
            {
                return(new UserViewModel
                {
                    UserId = -1,
                    Email = "",
                    UserFirstName = "",
                    UserLastName = "",
                    Token = "",
                    Password = "",
                    Message = "Failed to Find this user",
                    Address = "",
                    Province = "",
                    City = "",
                    PostCode = "",
                    PhoneNumber = "",
                });
            }
        }