Esempio n. 1
0
        public IHttpActionResult Login(Customer customer)
        {
            try
            {
                var token = new CustomerLogInBO().CustomerLogIn(customer.MobileNo, customer.Password);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    var _customer = new CustomerBO().GetCustomer(new Customer {
                        MobileNo = customer.MobileNo
                    });
                    if (_customer.IsOTPVerified)
                    {
                        return(Ok(new
                        {
                            token = token
                        }));
                    }
                    else
                    {
                        return(Ok("OTP not Verified...!"));
                    }
                }

                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 2
0
        public IHttpActionResult Logout()
        {
            try
            {
                IEnumerable <string> headerValues;
                var token = string.Empty;
                if (Request.Headers.TryGetValues("AUTH_TOKEN", out headerValues))
                {
                    token = headerValues.FirstOrDefault();
                }
                var result = new CustomerLogInBO()
                             .DeleteCustomerLogIn(new CustomerLogin {
                    TokenNo = token
                });

                if (result)
                {
                    return(Ok(UTILITY.LOGOUT));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 3
0
        public IHttpActionResult Login(Customer customer)
        {
            try
            {
                var token = new CustomerLogInBO().CustomerLogIn(customer.MobileNo, customer.Password);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    var _customer = new CustomerBO().GetCustomer(new Customer {
                        MobileNo = customer.MobileNo
                    });
                    if (_customer.IsOTPVerified)
                    {
                        return(Ok(new
                                  { Token = token, Status = UTILITY.SUCCESSTATUS }));
                    }
                    else
                    {
                        return(Ok(new { Token = "", Status = UTILITY.FAILURESTATUS }));
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 4
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var TYPE = HttpContext.Current.Request.Headers["TYPE"];

            if (string.IsNullOrWhiteSpace(TYPE))
            {
                var AUTH_TOKEN = HttpContext.Current.Request.Headers["AUTH_TOKEN"];
                var MOBILENO   = HttpContext.Current.Request.Headers["MOBILENO"];
                if (!string.IsNullOrWhiteSpace(AUTH_TOKEN) && !string.IsNullOrWhiteSpace(MOBILENO))
                {
                    var result = new CustomerLogInBO().AuthUser(
                        new CustomerLogin {
                        TokenNo = AUTH_TOKEN, MobileNo = MOBILENO
                    });

                    if (!result)
                    {
                        actionContext.Response = new HttpResponseMessage
                        {
                            Content    = new StringContent(UTILITY.INVALID),
                            StatusCode = HttpStatusCode.Unauthorized
                        };
                    }
                }
                else
                {
                    actionContext.Response = new HttpResponseMessage
                    {
                        Content    = new StringContent(UTILITY.FAILEDAUTH),
                        StatusCode = HttpStatusCode.Unauthorized
                    };
                }
            }
            else if (TYPE == "DRIVER")
            {
                var AUTH_TOKEN = HttpContext.Current.Request.Headers["AUTH_TOKEN"];
                var DRIVERID   = HttpContext.Current.Request.Headers["DRIVERID"];
                var LATITUDE   = HttpContext.Current.Request.Headers["LATITUDE"];
                var LONGITUDE  = HttpContext.Current.Request.Headers["LONGITUDE"];

                if (!string.IsNullOrWhiteSpace(AUTH_TOKEN) && !string.IsNullOrWhiteSpace(DRIVERID))
                {
                    var result = new DriverActivityBO().AuthenticateDriver(new DriverActivity {
                        TokenNo   = AUTH_TOKEN,
                        DriverID  = DRIVERID,
                        Latitude  = Convert.ToDecimal(LATITUDE),
                        Longitude = Convert.ToDecimal(LONGITUDE)
                    });

                    if (!result)
                    {
                        actionContext.Response = new HttpResponseMessage
                        {
                            Content    = new StringContent(UTILITY.INVALID),
                            StatusCode = HttpStatusCode.Unauthorized
                        };
                    }
                }
                else
                {
                    actionContext.Response = new HttpResponseMessage
                    {
                        Content    = new StringContent(UTILITY.FAILEDAUTH),
                        StatusCode = HttpStatusCode.Unauthorized
                    };
                }
            }
        }