Пример #1
0
 public User CreateModel(CreateUserModel 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.City = model.City;
   result.FavoriteEventType = model.FavoriteEventType;
   result.GenderType = model.GenderType;
   return result;
 }
Пример #2
0
        public async Task<IHttpActionResult> Register(CreateUserModel createUserModel)
        {
            // validate model
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            var user = AppModelFactory.CreateModel(createUserModel);
            var addUserResult = await this.AppUserManager.CreateAsync(user, createUserModel.Password);

            if (!addUserResult.Succeeded)
            {
                return GetErrorResult(addUserResult);
            }

            var locationHeader = new Uri(Url.Link("GetUserById", new { id = user.Id }));
            return Created(locationHeader, AppModelFactory.CreateViewModel(user));
        }