//[HttpGet]
        //public ActionResult GetUserDetail(int LoginID = 0)
        //{
        //    if (LoginID > 0)
        //    {
        //        UserDetailModel objUD = this.objUDSvc.QueryableUserDetailModel().Where(x => x.loginID == LoginID).FirstOrDefault();
        //        AddressViewModel objBA = this.objUDSvc.GetBillingAddresses(LoginID, true).FirstOrDefault();
        //        LoginDetailModel objLD = this.objUDSvc.GetLoginDetailByLoginID(LoginID);
        //        objLD.password = "";
        //        return Json(new Response { IsSuccess = true, Result = new { UserDetail = objUD, Address = objBA, Login = objLD } }, JsonRequestBehavior.AllowGet);
        //    }
        //    return Json(new Response { IsSuccess = false, Message = string.Format(StringResource.Invalid, "Session") }, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult BlockSite()
        {
            BlockSiteHistoryModel objBS = this.objUDSvc.GetLastBlockSiteHistory();
            bool isSiteBlocked          = objBS == null ? false : objBS.Isblocked;

            return(View(isSiteBlocked));
        }
        public int AddLastBlockSiteHistory(BlockSiteHistoryModel obj)
        {
            BlockSiteHistoryModel objBS = GetLastBlockSiteHistory();

            obj.Isblocked = objBS == null ? true : !objBS.Isblocked;
            obj.Createdon = DateTime.Now;
            uow.BlockSiteHistoryModel.Add(obj);
            return(uow.Save());
        }
Ejemplo n.º 3
0
        //// public ActionResult Login(LoginViewModel obj)

        public ActionResult Login(LoginData objd)

        {
            try
            {
                LoginViewModel obj = new LoginViewModel();
                obj.Username   = objd.Username;
                obj.Password   = objd.Password;
                obj.DeviceName = objd.DeviceName;
                obj.IpAddress  = Request.UserHostAddress;

                objd.IpAddress = obj.IpAddress;

                //string LocationName = "Mumbai";
                //string url = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false&key=AIzaSyDWb21fb6IJQYHxyqorDXuQujgEAgbSzLY", objd.Latitude, objd.Longitude);
                //XElement xml = XElement.Load(url);
                //if (xml.Element("status").Value == "OK")
                //{
                //    LocationName = string.Format("{0}",
                //        xml.Element("result").Element("formatted_address").Value);
                //}
                // objd.LocationName = LocationName;



                TokenLogModel objToken = this.objUDSvc.Login(obj);
                //  Session["Token"] = objToken;
                if (objToken != null)
                {
                    objd.LoginID = objToken.loginID;

                    if (objToken.RoleID == 3)
                    {
                        bool location = this.objUDSvc.GeoLocation(objd);
                        bool log      = this.objUDSvc.UserActivitylogs(objToken.loginID, "User Login", "Login Successfully.");
                    }
                    BlockSiteHistoryModel objBS = this.objUDSvc.GetLastBlockSiteHistory();
                    objToken.IsSiteBlocked = objBS == null ? false : objBS.Isblocked;
                    if (objToken.IsSiteBlocked == true && objToken.RoleID == 3)
                    {
                        Session["Token"] = null;
                    }
                    else
                    {
                        Session["Token"] = objToken;

                        UserMenuAccessModel objAccess = new UserMenuAccessModel();
                        objAccess             = this.objUDSvc.UserMenuAccessModel(objToken.loginID, "", "", "MenuAccessDetails");
                        Session["MenuAccess"] = objAccess;
                    }
                    return(Json(new Response {
                        IsSuccess = true, Message = "", Result = objToken
                    }));
                }
                else
                {
                    // bool log = this.objUDSvc.UserActivitylog(objToken.loginID, "User Login", "Login Failed.");

                    return(Json(new Response {
                        IsSuccess = false, Message = StringResource.InvalidPassword, Result = objToken
                    }));
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("HomeController", "GenerateOtp", ex);
                return(Json(new Response {
                    IsSuccess = false, Message = ex.Message
                }));
            }
        }