// GET: Order
 public ActionResult AddOrder()
 {
     if (Session["UserId"] == null)
         return RedirectToAction("Login", "Account");
     Utilities.Shop _ShopUtility = new Utilities.Shop();
     List<Models.Shop> Shopslist = new List<Models.Shop>();
     Shopslist = _ShopUtility.GetAllShops();
     return View(Shopslist);
 }
 public ActionResult OrdersManagement()
 {
     if (Session["UserId"] == null || Session["IsAdmin"].ToString() == "1")
         return RedirectToAction("Login", "Account");
     Utilities.Shop _ShopUtility = new Utilities.Shop();
     List<Models.Shop> Shopslist = new List<Models.Shop>();
     Shopslist = _ShopUtility.GetAllShops();
     return View(Shopslist);
 }
        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));
        }
        public ActionResult UpdateShopInfo(string Id, string Name, string ShopArea, string UserId, string Image, string Notes, string Status, string MobileNumber, int MaxOrderCount)
        {
            Dictionary <string, object> returnObject = new Dictionary <string, object>();

            try
            {
                bool           Result      = false;
                Utilities.Shop shopUtility = new Utilities.Shop();
                var            ShopInfo    = shopUtility.GetShopById(Id);
                if (string.IsNullOrEmpty(Image))
                {
                    Image = ShopInfo.Image;
                }
                else
                {
                    string path = Server.MapPath("~" + Globals.Default_ShopImagePath); //Path

                    //Check if directory exist
                    if (!System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist
                    }

                    string imageName = Guid.NewGuid().ToString() + ".jpg";

                    //set the image path
                    string imgPath      = Path.Combine(path, imageName);
                    var    splitedValue = Image.Split(',');
                    var    ReplaceValue = splitedValue[0] + ',';
                    Image = Image.Replace(ReplaceValue, "");
                    var imageBytes = Convert.FromBase64String(Image);

                    System.IO.File.WriteAllBytes(imgPath, imageBytes);
                    Image = Globals.Default_ShopImagePath + "/" + imageName;
                }
                Result   = _shopData.Update(Id, Name, ShopArea, UserId, Image, Notes, Status, MobileNumber, MaxOrderCount);
                ShopInfo = shopUtility.GetShopById(Id);
                Utilities.User userUtility           = new Utilities.User();
                var            ShopConnectedUserInfo = userUtility.GetShopConnectedUserInfo(ShopInfo.Id);
                if (Result == true)
                {
                    returnObject.Add("ShopInfo", ShopInfo);
                    returnObject.Add("ShopConnectedUserInfo", ShopConnectedUserInfo);
                    returnObject.Add("status", "success");
                }
                else
                {
                    returnObject.Add("status", "fail");
                }
            }
            catch (Exception)
            {
            }
            return(Json(new { message = returnObject }, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult ViewAllShops()
        {
            if (Session["UserId"] == null || Session["IsAdmin"].ToString() == "1")
            {
                return(RedirectToAction("Login", "Account"));
            }
            Utilities.Shop     _ShopUtility = new Utilities.Shop();
            List <Models.Shop> Shopslist    = new List <Models.Shop>();

            Utilities.User _UserUtility = new Utilities.User();
            List <Models.ShopAdditionalInfo> ShopAdditionalInfoList = new List <Models.ShopAdditionalInfo>();

            Shopslist = _ShopUtility.GetAllShops();

            foreach (Models.Shop shop in Shopslist)
            {
                Models.ShopAdditionalInfo shopAdditionalInfo = new Models.ShopAdditionalInfo();
                shopAdditionalInfo.Id       = shop.Id;
                shopAdditionalInfo.Name     = shop.Name;
                shopAdditionalInfo.ShopArea = shop.ShopArea;
                shopAdditionalInfo.Image    = shop.Image;
                shopAdditionalInfo.Notes    = shop.Notes;
                if (shop.Status == "active")
                {
                    shopAdditionalInfo.Status = "card-success";
                }
                else
                {
                    shopAdditionalInfo.Status = "card-danger";
                }
                shopAdditionalInfo.CreatedDate     = shop.CreatedDate;
                shopAdditionalInfo.ModifiedDate    = shop.ModifiedDate;
                shopAdditionalInfo.MobileNumber    = shop.MobileNumber;
                shopAdditionalInfo.MaxOrderCount   = shop.MaxOrderCount;
                shopAdditionalInfo.TodaysOderCount = shop.TodaysOderCount;
                shopAdditionalInfo.UserInfo        = _UserUtility.GetShopConnectedUserInfo(shop.Id);
                ShopAdditionalInfoList.Add(shopAdditionalInfo);
            }
            return(View(ShopAdditionalInfoList));
        }
예제 #6
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);
        }
        public ActionResult GetAllOrdersDates(string ShopId, string FilterDate)
        {
            Dictionary <string, object> returnObject = new Dictionary <string, object>();

            try
            {
                List <Models.Order> OrderList = new List <Models.Order>();
                OrderList = _orderUtility.GetAllOrdersDates(ShopId, FilterDate);
                if (OrderList != null)
                {
                    if (!string.IsNullOrEmpty(ShopId))
                    {
                        int awaitingOrdersCount   = OrderList.Where(x => x.Status == "awaiting").ToList().Count;
                        int inprogressOrdersCount = OrderList.Where(x => x.Status == "inprogress").ToList().Count;
                        int completedOrdersCount  = OrderList.Where(x => x.Status == "completed").ToList().Count;
                        int droppedOrdersCount    = OrderList.Where(x => x.Status == "dropped").ToList().Count;

                        List <int> _totalAmount = OrderList.Select(x => x.Amount).ToList();
                        int        TotalAmout   = 0;

                        if (_totalAmount != null && _totalAmount.Count > 0)
                        {
                            TotalAmout = _totalAmount.Take(_totalAmount.Count).Sum();
                        }

                        List <int> _receivedAmount = OrderList.Where(x => x.Status == "completed").Select(x => x.Amount).ToList();
                        int        ReceivedAmout   = 0;

                        if (_receivedAmount != null && _receivedAmount.Count > 0)
                        {
                            ReceivedAmout = _receivedAmount.Take(_receivedAmount.Count).Sum();
                        }



                        returnObject.Add("awaitingOrdersCount", awaitingOrdersCount);
                        returnObject.Add("inprogressOrdersCount", inprogressOrdersCount);
                        returnObject.Add("completedOrdersCount", completedOrdersCount);
                        returnObject.Add("droppedOrdersCount", droppedOrdersCount);

                        returnObject.Add("TotalAmount", TotalAmout);
                        returnObject.Add("ReceivedAmount", ReceivedAmout);
                        returnObject.Add("BalanceAmount", TotalAmout - ReceivedAmout);
                    }
                    else
                    {
                        Utilities.Shop shopUtility = new Utilities.Shop();
                        var            ShopsList   = shopUtility.GetAllShopsByStaus(true);

                        if (ShopsList != null && ShopsList.Count > 0)
                        {
                            List <Models.ShopInfoForChart> shopInfoForChartsList = new List <Models.ShopInfoForChart>();
                            foreach (var Shop in ShopsList)
                            {
                                var SingleShopOrderList = _orderUtility.GetAllOrdersDates(Shop.Id, FilterDate);

                                int awaitingOrdersCount   = SingleShopOrderList.Where(x => x.Status == "awaiting").ToList().Count;
                                int inprogressOrdersCount = SingleShopOrderList.Where(x => x.Status == "inprogress").ToList().Count;
                                int completedOrdersCount  = SingleShopOrderList.Where(x => x.Status == "completed").ToList().Count;
                                int droppedOrdersCount    = SingleShopOrderList.Where(x => x.Status == "dropped").ToList().Count;

                                List <int> _totalAmount = SingleShopOrderList.Select(x => x.Amount).ToList();
                                int        TotalAmout   = 0;

                                if (_totalAmount != null && _totalAmount.Count > 0)
                                {
                                    TotalAmout = _totalAmount.Take(_totalAmount.Count).Sum();
                                }

                                List <int> _receivedAmount = SingleShopOrderList.Where(x => x.Status == "completed").Select(x => x.Amount).ToList();
                                int        ReceivedAmout   = 0;

                                if (_receivedAmount != null && _receivedAmount.Count > 0)
                                {
                                    ReceivedAmout = _receivedAmount.Take(_receivedAmount.Count).Sum();
                                }

                                Models.ShopInfoForChart shopInfoForChart = new Models.ShopInfoForChart()
                                {
                                    Id   = Shop.Id,
                                    Name = Shop.Name,

                                    TotalOrdersCount      = SingleShopOrderList.Count,
                                    AwaitingOrdersCount   = awaitingOrdersCount,
                                    InprogressOrdersCount = inprogressOrdersCount,
                                    CompletedOrdersCount  = completedOrdersCount,
                                    DroppedOrdersCount    = droppedOrdersCount,

                                    TotalAmount    = TotalAmout,
                                    ReceivedAmount = ReceivedAmout,
                                    BalanceAmount  = TotalAmout - ReceivedAmout
                                };
                                shopInfoForChartsList.Add(shopInfoForChart);
                            }
                            returnObject.Add("ShopInfoForChartsList", shopInfoForChartsList);
                        }
                    }
                    returnObject.Add("OrderList", OrderList);
                    returnObject.Add("status", "success");
                }
                else
                {
                    returnObject.Add("status", "fail");
                }
            }
            catch (Exception exe)
            {
            }
            return(Json(new { message = returnObject }, JsonRequestBehavior.AllowGet));
        }