public async Task <HttpResponseMessage> Register(RegistrationAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, string.Join(", ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)))); } try { if (model.DateOfBirth <= DateTime.MinValue) { throw new ArgumentException("Please Select your Date of Birth"); } IdentityUser user = _userService.CreateUser(model.Email, model.Password); if (user != null) { RegistrationResponse response = new RegistrationResponse(); response.AspNetUserID = user.Id; response.Email = model.Email; response.MemberProfileId = _memberProfileService.Insert(new MemberProfileAddRequest { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Gender = model.Gender, DateOfBirth = model.DateOfBirth, AspNetUserID = user.Id, IsActive = true, IsPublic = true, IsViewable = true }); if (response.MemberProfileId > 0) { try { AppTokenResponse tokenResponse = new AppTokenResponse(); AppTokenAddRequest tokenObject = new AppTokenAddRequest() { MemberProfileId = response.MemberProfileId, TokenTypeId = (int)AppTokenType.ConfirmRegistration }; tokenResponse.TokenGuid = _appTokenService.Insert(tokenObject); await _sendEmailService.SendEmailRegConfirm(response.Email, tokenResponse.TokenGuid); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch { throw; } } } return(Request.CreateResponse(HttpStatusCode.OK, "Registration Success")); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }