public ActionResult ValidateUserLogin(string MobileNumber, string Password, bool IsRemember)
        {
            Dictionary <string, object> returnObject = new Dictionary <string, object>();

            try
            {
                var UserInfo = _userData.ValidateUserLogin(MobileNumber, Password);
                if (UserInfo != null && !string.IsNullOrEmpty(UserInfo.Id))
                {
                    Session["UserId"]    = UserInfo.Id;
                    Session["IsAdmin"]   = UserInfo.IsAdmin;
                    Session["Name"]      = UserInfo.Name;
                    Session["UserImage"] = UserInfo.Image;
                    returnObject.Add("userInfo", UserInfo);


                    if (UserInfo.IsAdmin == 0)
                    {
                        Utilities.Shop _shopUtility = new Utilities.Shop();
                        var            ShopInfo     = _shopUtility.GetUserConnectedShopInfo(UserInfo.Id);
                        if (ShopInfo != null && !string.IsNullOrEmpty(ShopInfo.Id))
                        {
                            Session["ShopId"] = ShopInfo.Id;
                            returnObject.Add("status", "success");
                        }
                        else
                        {
                            returnObject.Add("status", "fail");
                            returnObject.Add("errorMessage", "You are Not Connected any Shop, Contact Admin");
                        }
                    }
                    else
                    {
                        returnObject.Add("status", "success");
                    }

                    if (IsRemember)
                    {
                        HttpCookie cookie = new HttpCookie("Login");
                        cookie.Values.Add("MobileNumber", UserInfo.MobileNumber);
                        cookie.Values.Add("PWD", UserInfo.Password);
                        cookie.HttpOnly = true;
                        cookie.Expires  = DateTime.Now.AddDays(30);
                        Response.Cookies.Add(cookie);
                    }
                }
                else
                {
                    returnObject.Add("status", "fail");
                }
            }
            catch (Exception exe)
            {
            }
            return(Json(new { message = returnObject }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult viewAllUser()
        {
            if (Session["UserId"] == null || Session["IsAdmin"].ToString() == "1")
                return RedirectToAction("Login", "Account");
            Utilities.User _UserUtility = new Utilities.User();
            Utilities.Shop _ShopUtility = new Utilities.Shop();

            List<Models.User> UsersList = _UserUtility.GetAllUsers();
            List<Models.UserAdditionalInfo> UserAdditionalInfoList = new List<Models.UserAdditionalInfo>();

            foreach(Models.User user in UsersList)
            {
                Models.UserAdditionalInfo userAdditionalInfo = new Models.UserAdditionalInfo();
                userAdditionalInfo.Id = user.Id;
                userAdditionalInfo.Name = user.Name;
                userAdditionalInfo.EmailId = user.EmailId;
                userAdditionalInfo.Password = user.Password;
                userAdditionalInfo.Image = user.Image;
                if(user.Status == "active")
                {
                    userAdditionalInfo.Status = "card-success";
                }
                else
                {
                    userAdditionalInfo.Status = "card-danger";
                }
                userAdditionalInfo.Area = user.Area;
                userAdditionalInfo.Notes = user.Notes;
                userAdditionalInfo.CreatedDate = user.CreatedDate;
                userAdditionalInfo.ModifiedDate = user.ModifiedDate;
                userAdditionalInfo.MobileNumber = user.MobileNumber;
                userAdditionalInfo.IsAdmin = user.IsAdmin;
                userAdditionalInfo.ShopInfo = _ShopUtility.GetUserConnectedShopInfo(user.Id);
                UserAdditionalInfoList.Add(userAdditionalInfo);
            }
            return View(UserAdditionalInfoList);
        }