예제 #1
0
        public ActionResult AddShopImage(HttpPostedFileBase ShopImageFile, string txtImageTitle, string chkSlider, string UserId)
        {
            try
            {
                string USER_id = new SecurityManager().DecodeString(UserId);
                User UserObj = new User().GetUser(Convert.ToInt64(USER_id));
                string savedFileName = "";
                if (ShopImageFile != null)
                {
                    savedFileName = uploadProfileImage(ShopImageFile, UserObj.UserId);
                    if (!string.IsNullOrWhiteSpace(savedFileName))
                    {

                        Shop_Image shopImage = new Shop_Image();
                        shopImage.User_Id = UserObj.UserId;
                        shopImage.Image_Title = txtImageTitle;
                        shopImage.Image_Path = savedFileName;
                        shopImage.Is_For_Home_Page_Slider = false;
                        shopImage.Created_On = DateTime.Now;
                        if (!string.IsNullOrWhiteSpace(chkSlider) && chkSlider.Equals("1"))
                        {
                            shopImage.Is_For_Home_Page_Slider = true;
                        }
                        shopImage.AddShopImage(shopImage);
                        shopImage = null;
                    }
                }
                UserObj = null;
            }
            catch (Exception)
            {
            }
            return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = UserId }));
        }
예제 #2
0
        public long AddShopImage(Shop_Image shopImage)
        {
            try
            {

                using (shoponlineDataContext context = DbUtils.Create())
                {
                    context.Shop_Images.InsertOnSubmit(shopImage);
                    context.SubmitChanges();
                    return shopImage.Shop_Image_Id;

                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
예제 #3
0
        public ActionResult DeleteShopImage(string Shop_Image_Id)
        {
            try
            {
                string imageId = new SecurityManager().DecodeString(Shop_Image_Id);

                Shop_Image shopImage = new Shop_Image().GetShopImage(Convert.ToInt64(imageId));
                if (shopImage != null)
                {
                    Int64 UserId = shopImage.User_Id;
                    deleteUploadedImage(shopImage.Image_Path, UserId);
                    new Shop_Image().DeleteShopImage(shopImage.Shop_Image_Id);

                    string Enc_UserId = new SecurityManager().EncodeString(Convert.ToString(UserId));
                    return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopImages", action = "Index", Id = Enc_UserId }));

                }

            }
            catch (Exception)
            {
            }
            return RedirectToRoute(new RouteValueDictionary(new { controller = "Home", action = "Dashboard" }));
        }