예제 #1
0
 internal User CreateModel(UserModel model, User datamodel = null)
 {
   var result = datamodel ?? new User();
   result.DateOfBirth = model.DateOfBirth;
   result.UserName = model.Username;
   result.Email = model.Email;
   result.Forename = model.Forename;
   result.Surname = model.Surname;
   result.AvatarId = model.AvatarId;
   result.City = model.City;
   result.FavoriteEventType = model.FavoriteEventType;
   result.GenderType = model.GenderType;
   return result;
 }
예제 #2
0
        public async Task<IHttpActionResult> UpdateCurrentUser(UserModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var currentUserId = User.Identity.GetUserId();
            var user = await this.AppUserManager.FindByIdAsync(currentUserId);
            user = this.AppModelFactory.CreateModel(model, user);
            var result = await this.AppUserManager.UpdateAsync(user);
            return !result.Succeeded ? GetErrorResult(result) : StatusCode(HttpStatusCode.NoContent);
        }