コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }