public async Task<JsonResult> Register(RegisterModel model) { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(ModelState.Errors()); } if (!(await _userProfileService.UserNameExist(model.Name) && await _userProfileService.UserEmailExist(model.Email))) { _userProfileService.CreateUserProfile(Mapper.ToBllUserProfileRegisterModel(model)); return Json(new HttpResponseMessage(HttpStatusCode.NoContent)); } ModelState.AddModelError("Error", "User with this login or email already exist"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(ModelState.Errors()); }
internal static BllUserProfile ToBllUserProfileRegisterModel(RegisterModel model) { if (model != null) return new BllUserProfile { Name = model.Name, Password = model.Password, Email = model.Email, Photo = model.Photo, TimeRegister = DateTime.Now }; return null; }