Exemplo n.º 1
0
        public async Task <AspNetUserInfo> GetAccountInfoByUserId(string UserId)
        {
            var output = new AspNetUserInfo();

            output.AspNetUsers = await AspNetUsersGetById(UserId);

            output.AspNetUserProfiles = await AspNetUserProfilesGetByUserId(UserId);

            output.AspNetUserRoles = await AspNetUserRolesGetByUserId(UserId);

            return(output);
        }
Exemplo n.º 2
0
        public IHttpActionResult DeleteAspNetUserInfo(string id)
        {
            AspNetUserInfo aspNetUserInfo = db.AspNetUserInfoes.Find(id);

            if (aspNetUserInfo == null)
            {
                return(NotFound());
            }

            db.AspNetUserInfoes.Remove(aspNetUserInfo);
            db.SaveChanges();

            return(Ok(aspNetUserInfo));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostAspNetUserInfo(UserInfoModel userInfoModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AspNetUserInfo aspNetUserInfo = new AspNetUserInfo()
            {
                Id        = Guid.NewGuid().ToString(),
                FirstName = userInfoModel.FirstName,
                LastName  = userInfoModel.LastName,
                Gender    = userInfoModel.Gender,
                DOB       = userInfoModel.DOB,
                UsersId   = db.AspNetUsers.FirstOrDefault(i => i.UserName == userInfoModel.userInfoViewModel.UserName).Id
            };

            db.AspNetUserInfoes.Add(aspNetUserInfo);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (AspNetUserInfoExists(aspNetUserInfo.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(new { Message = "SUCCESS" }));
        }
Exemplo n.º 4
0
        public IHttpActionResult PutAspNetUserInfo(string id, UserInfoModel userInfoModel)
        {
            ModelState.Where(m => m.Key == "userInfoModel.userInfoViewModel.Password").FirstOrDefault().Value.Errors.Clear();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userInfoModel.UsersId)
            {
                return(BadRequest());
            }

            AspNetUserInfo aspNetUserInfo = new AspNetUserInfo()
            {
                Id        = userInfoModel.Id.ToString(),
                FirstName = userInfoModel.FirstName,
                LastName  = userInfoModel.LastName,
                Gender    = userInfoModel.Gender,
                DOB       = userInfoModel.DOB,
                UsersId   = userInfoModel.UsersId
            };

            AspNetUser aspNetUser = new AspNetUser()
            {
                Email                = userInfoModel.userInfoViewModel.Email,
                EmailConfirmed       = userInfoModel.userInfoViewModel.Email == userInfoModel.userInfoViewModel.ConfirmEmail ? true : false,
                PhoneNumber          = userInfoModel.userInfoViewModel.Phone,
                PhoneNumberConfirmed = userInfoModel.userInfoViewModel.Phone == userInfoModel.userInfoViewModel.ConfirmPhone ? true : false,
                Id            = userInfoModel.userInfoViewModel.UserId,
                UserName      = userInfoModel.userInfoViewModel.UserName,
                PasswordHash  = ((AspNetUser)db.AspNetUsers.AsNoTracking().Where(i => i.Id == userInfoModel.userInfoViewModel.UserId).FirstOrDefault()).PasswordHash,
                SecurityStamp = ((AspNetUser)db.AspNetUsers.AsNoTracking().Where(i => i.Id == userInfoModel.userInfoViewModel.UserId).FirstOrDefault()).SecurityStamp
            };

            db.Entry(aspNetUserInfo).State = EntityState.Modified;
            db.Entry(aspNetUser).State     = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AspNetUserInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok(new { Message = "SUCCESS" }));
        }