public IHttpActionResult SendOTPForLogin(SendOTPForLoginRequest sendOTPForLoginRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var account = new Account() { Mobile = sendOTPForLoginRequest.Mobile }; int resultCheckUserExists = iAccount.CheckUserExists(account); if (resultCheckUserExists > 0 && resultCheckUserExists == Convert.ToInt32(Utility.Roles.User)) { account.MobileOTP = Utility.RandomOtpMobile(); string oTPResult = Utility.SendOTPOnSMS(sendOTPForLoginRequest.Mobile, Utility.LoginRegister.Login.ToString(), account.MobileOTP); dynamic deserializeOTPResult = JsonConvert.DeserializeObject <dynamic>(oTPResult); if (deserializeOTPResult.Status == Utility.SUCCESS_STATUS_RESPONSE) { int result = iAccount.OTPUpdateForLogin(account); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "OTP sent successfully."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Invalid Mobile."; } } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Invalid Mobile."; } } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Invalid Mobile."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while sending OTP."; Utility.WriteLog("SendOTPForLogin", sendOTPForLoginRequest, "Error while sending OTP. (AccountGuestController)", ex.ToString()); } return(Ok(responses)); }