Пример #1
0
 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());
 }
Пример #2
0
 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;
 }