public IHttpActionResult Post(AppTokenAddRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _appTokenService.Insert(model); return(Ok(new SuccessResponse())); } catch (Exception ex) { int currentUser = _userService.GetCurrentUserId(); _appLogService.Insert(new AppLogAddRequest { AppLogTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name, UserBaseId = currentUser }); return(BadRequest(ex.Message)); } }
public async Task <HttpResponseMessage> ForgotPassword(LoginEmailRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, string.Join(",", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)))); } SuccessResponse response = new SuccessResponse(); try { bool validUser = _userService.IsUser(model.Email); if (validUser) { AppTokenAddRequest token = new AppTokenAddRequest(); MemberProfile _memberProfile = _memberProfileService.SelectByEmail(model.Email); token.MemberProfileId = _memberProfile.Id; token.TokenTypeId = (int)AppTokenType.ResetPassword; Guid _guid = _appTokenService.Insert(token); await _sendEmailService.SendEmailForgotPassword(model.Email, _guid); return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Email Doesn't Exist")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public void Insert(AppTokenAddRequest model) { DataProvider.ExecuteNonQuery("dbo.AppToken_Insert", inputParamMapper: (SqlParameterCollection inputs) => { inputs.AddWithValue("@UserBaseId", model.UserBaseId); inputs.AddWithValue("@Token", model.Token); inputs.AddWithValue("@AppTokenTypeId", model.AppTokenTypeId); }); }
public HttpResponseMessage Insert(AppTokenAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState)); } SuccessResponse response = new SuccessResponse(); try { _appTokenService.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
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)); } }