Exemplo n.º 1
0
        public HttpResponseMessage ActivateRegisteredUser([FromBody] OtpRequest request)
        {
            try
            {
                if (request != null)
                {
                    // Uncomment below line if you want to verify otp sent over sms
                    //OtpResponse smsResponse = notification.VerifyOTP(request);
                    OtpResponse emailResponse = emailNotification.VerifyOTP(request);

                    if (emailResponse.Status == "Success")
                    {
                        string password = new LoginHelper().GeneratePassword(8);

                        int result = bll.ActivateRegisteredUser(request.Mobile, password, request.Email, request.Otp);

                        // Uncomment below lines if you want to send first time login details over sms

                        //LoginDetails req = new LoginDetails()
                        //{
                        //    From = "VHAASH",
                        //    To = request.Mobile,
                        //    TemplateName = "ScoopenLoginAccount",
                        //    VAR1 = "User",
                        //    VAR2 = request.Mobile,
                        //    VAR3 = password
                        //};

                        //OtpResponse smsResponseLoginDetails = notification.SendLoginDetails(req);

                        LoginDetails emailreq = new LoginDetails()
                        {
                            From         = "VHAASH",
                            To           = request.Email,
                            TemplateName = "ScoopenLoginAccount",
                            VAR1         = "User",
                            VAR2         = request.Mobile,
                            VAR3         = password
                        };

                        OtpResponse emailResponseLoginDetails = emailNotification.SendLoginDetails(emailreq);

                        return(Request.CreateResponse(HttpStatusCode.OK, emailResponseLoginDetails));
                    }

                    return(Request.CreateErrorResponse(HttpStatusCode.NonAuthoritativeInformation, "OTP Not Matched"));
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest, ""));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }