public ActionResult GetShopInfoById(string Id) { Dictionary <string, object> returnObject = new Dictionary <string, object>(); try { Models.Shop shopInfo = new Models.Shop(); shopInfo = _shopData.GetShopById(Id); Utilities.User userUtility = new Utilities.User(); var UserInfo = userUtility.GetShopConnectedUserInfo(shopInfo.Id); if (shopInfo != null && !string.IsNullOrEmpty(shopInfo.Id)) { var usersList = _userData.GetAllUsersByStatus(true); returnObject.Add("shopInfo", shopInfo); returnObject.Add("ShopConnecteduserId", UserInfo.Id); returnObject.Add("usersList", usersList); returnObject.Add("status", "success"); } else { returnObject.Add("status", "fail"); } } catch (Exception) { } 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)); }
// GET: Shop public ActionResult AddShop() { if (Session["UserId"] == null || Session["IsAdmin"].ToString() == "1") { return(RedirectToAction("Login", "Account")); } Utilities.User _UserUtility = new Utilities.User(); List <Models.User> UsersList = _UserUtility.GetAllUsers(); UsersList = UsersList.Where(x => x.Status == "active").ToList(); return(View(UsersList)); }
public ActionResult UserProfile() { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Account")); } Utilities.User userUtility = new Utilities.User(); string UserId = Session["UserId"].ToString(); var UserInfo = userUtility.GetUserById(UserId); return(View(UserInfo)); }
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)); }
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); }