Пример #1
0
        public ActionResult EditeSlider(Sliders model, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    System.IO.File.Delete(Server.MapPath(model.ImageSlider));
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/") + filename);
                    model.ImageSlider = "/img/" + filename;
                }

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect("/Admin/Home/Sliders"));
            }
            foreach (var VARIABLE in liStrings)
            {
                data_transition.Add(new SelectListItem()
                {
                    Text  = VARIABLE,
                    Value = VARIABLE
                });
            }
            ViewBag.data_transition      = new SelectList(data_transition, "Value", "Text", model.data_transition);
            ViewBag.data_slotamount      = new SelectList(data_slotamount, "Value", "Text", model.data_slotamount);
            ViewBag.data_masterspeed     = new SelectList(data_masterspeed, "Value", "Text", model.data_masterspeed);
            ViewBag.data_Delay           = new SelectList(data_Delay, "Value", "Text", model.data_Delay);
            ViewBag.data_saveperformance = new SelectList(data_saveperformance, "Value", "Text", model.data_saveperformance);
            ViewBag.Imagedatabgposition  = new SelectList(Imagedatabgposition, "Value", "Text", model.Imagedatabgposition);
            ViewBag.Imagedatabgfit       = new SelectList(Imagedatabgfit, "Value", "Text", model.Imagedatabgfit);
            return(View(model));
        }
Пример #2
0
        public ActionResult AddLayerToSlider(LayerSliders model, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/") + filename);
                    model.LayerImage = "/img/" + filename;
                }

                db.LayerSliderses.Add(model);
                db.SaveChanges();
                return(Redirect("/Admin/Home/LayerSlider/" + model.SlideID));
            }
            foreach (var VARIABLE in data_easinglist)
            {
                data_easing.Add(new SelectListItem()
                {
                    Text  = VARIABLE,
                    Value = VARIABLE
                });
            }
            ViewBag.data_easing        = new SelectList(data_easing, "Value", "Text");
            ViewBag.data_splitin       = new SelectList(data_splitin, "Value", "Text");
            ViewBag.data_splitout      = new SelectList(data_splitout, "Value", "Text");
            ViewBag.data_captionhidden = new SelectList(data_captionhidden, "Value", "Text");
            ViewBag.data_endeasing     = new SelectList(data_easing, "Value", "Text");
            return(View(model));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "PostID,PostTitle,PostText,PostTypeID,PostShortDiscription,PostDate,KeyWord,UserID,PostImage,Vaziaat")] Post post, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/posts/") + filename);
                    ImageResizer nrResizer = new ImageResizer();
                    nrResizer.Resize(Server.MapPath("/img/posts/") + filename,
                                     Server.MapPath("/img/posts/265×176/") + filename, 265, 176);
                    nrResizer.Resize(Server.MapPath("/img/posts/") + filename,
                                     Server.MapPath("/img/posts/thum/") + filename, 150, 150);

                    post.PostImage = filename;
                }
                else
                {
                    post.PostImage = "nopic.jpg";
                }

                post.UserID          = db.Userses.Where(p => p.UserName == User.Identity.Name).SingleOrDefault().UserID;
                post.PostDate        = DateTime.Now;
                db.Entry(post).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostTypeID = new SelectList(db.PostTypes, "PostTypeID", "Title", post.PostTypeID);
            ViewBag.UserID     = new SelectList(db.Userses, "UserID", "FullName", post.UserID);
            return(View(post));
        }
Пример #4
0
 public ActionResult CreateSlider(Sliders model, HttpPostedFileBase img)
 {
     if (ModelState.IsValid)
     {
         if (CheckContentImage.IsImage(img) && img != null)
         {
             string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
             img.SaveAs(Server.MapPath("/img/") + filename);
             model.ImageSlider = "/img/" + filename;
             db.Sliderses.Add(model);
             db.SaveChanges();
             return(Redirect("/Admin/Home/Sliders"));
         }
         ModelState.AddModelError("ImageSlider", "لطفا تصویر خود را با فرمت مجاز ارسال فرمایید");
     }
     foreach (var VARIABLE in liStrings)
     {
         data_transition.Add(new SelectListItem()
         {
             Text  = VARIABLE,
             Value = VARIABLE
         });
     }
     ViewBag.data_transition      = new SelectList(data_transition, "Value", "Text");
     ViewBag.data_slotamount      = new SelectList(data_slotamount, "Value", "Text");
     ViewBag.data_masterspeed     = new SelectList(data_masterspeed, "Value", "Text");
     ViewBag.data_Delay           = new SelectList(data_Delay, "Value", "Text");
     ViewBag.data_saveperformance = new SelectList(data_saveperformance, "Value", "Text");
     ViewBag.Imagedatabgposition  = new SelectList(Imagedatabgposition, "Value", "Text");
     ViewBag.Imagedatabgfit       = new SelectList(Imagedatabgfit, "Value", "Text");
     return(View(model));
 }
Пример #5
0
        public ActionResult Edit([Bind(Include = "PostID,PostTitle,PostText,PostTypeID,PostShortDiscription,PostDate,KeyWord,UserID,PostImage,Vaziaat")] Post post, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    if (!post.PostImage.Contains("nopic"))
                    {
                        System.IO.File.Delete(Server.MapPath("/img/posts/") + post.PostImage);
                        System.IO.File.Delete(Server.MapPath("/img/posts/265×176/") + post.PostImage);
                        System.IO.File.Delete(Server.MapPath("/img/posts/thum/") + post.PostImage);
                    }
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/posts/") + filename);
                    ImageResizer nrResizer = new ImageResizer();
                    nrResizer.Resize(Server.MapPath("/img/posts/") + filename,
                                     Server.MapPath("/img/posts/265×176/") + filename, 265, 176);
                    nrResizer.Resize(Server.MapPath("/img/posts/") + filename,
                                     Server.MapPath("/img/posts/thum/") + filename, 150, 150);

                    post.PostImage = filename;
                }
                db.Entry(post).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.PostTypeID = new SelectList(db.PostTypes, "PostTypeID", "Title", post.PostTypeID);
            ViewBag.UserID     = new SelectList(db.Userses, "UserID", "FullName", post.UserID);
            return(View(post));
        }
 public ActionResult Edit([Bind(Include = "ProductTypeId,Title,image,Discription")] ProductType productType, HttpPostedFileBase img)
 {
     if (ModelState.IsValid)
     {
         if (img != null)
         {
             if (CheckContentImage.IsImage(img))
             {
                 if (!productType.image.Contains("nopic"))
                 {
                     System.IO.File.Delete(Server.MapPath("/img/Products/type/" + productType.image));
                     System.IO.File.Delete(Server.MapPath("/img/Products/type/thumline/" + productType.image));
                     System.IO.File.Delete(Server.MapPath("/img/Products/type/265×176/" + productType.image));
                 }
                 string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                 productType.image = filename;
                 img.SaveAs(Server.MapPath("/img/Products/type/" + filename));
                 ImageResizer imgs = new ImageResizer();
                 imgs.Resize(Server.MapPath("/img/Products/type/" + filename),
                             Server.MapPath("/img/Products/type/thumline/" + filename), 150, 150);
                 imgs.Resize(Server.MapPath("/img/Products/type/" + filename),
                             Server.MapPath("/img/Products/type/265×176/" + filename), 265, 176);
             }
             else
             {
                 ModelState.AddModelError("image", "لطفاْ تصویر خود را با فرمت مجاز وارد نمایید");
                 return(View(productType));
             }
         }
         db.Entry(productType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productType));
 }
        public ActionResult Create([Bind(Include = "ProductTypeId,Title,image,Discription")] ProductType productType, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    productType.image = filename;
                    img.SaveAs(Server.MapPath("/img/Products/type/" + filename));
                    ImageResizer imgs = new ImageResizer();
                    imgs.Resize(Server.MapPath("/img/Products/type/" + filename),
                                Server.MapPath("/img/Products/type/thumline/" + filename), 150, 150);
                    imgs.Resize(Server.MapPath("/img/Products/type/" + filename),
                                Server.MapPath("/img/Products/type/265×176/" + filename), 265, 176);
                }
                else
                {
                    ModelState.AddModelError("image", "لطفا تصویر شاخص را با فرمت های مجاز وارد نمایید.");
                    return(View(productType));
                }
                db.ProductTypes.Add(productType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productType));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "BrandID,BrandName,Image")] Brands brands, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/") + filename);
                    brands.Image = filename;
                    db.Brandses.Add(brands);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(brands));
        }
Пример #9
0
        public ActionResult EditLayerToSlider(LayerSliders model, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    if (!string.IsNullOrEmpty(model.LayerImage))
                    {
                        System.IO.File.Delete(Server.MapPath(model.LayerImage));
                    }
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/") + filename);
                    model.LayerImage = "/img/" + filename;
                    model.LayerText  = null;
                }

                if (!string.IsNullOrEmpty(model.LayerText))
                {
                    if (!string.IsNullOrEmpty(model.LayerImage))
                    {
                        System.IO.File.Delete(Server.MapPath(model.LayerImage));
                    }
                    model.LayerImage = null;
                }

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect("/Admin/Home/LayerSlider/" + model.SlideID));
            }
            foreach (var VARIABLE in data_easinglist)
            {
                data_easing.Add(new SelectListItem()
                {
                    Text  = VARIABLE,
                    Value = VARIABLE
                });
            }
            ViewBag.data_easing        = new SelectList(data_easing, "Value", "Text", model.data_easing);
            ViewBag.data_splitin       = new SelectList(data_splitin, "Value", "Text", model.data_splitin);
            ViewBag.data_splitout      = new SelectList(data_splitout, "Value", "Text", model.data_splitout);
            ViewBag.data_captionhidden = new SelectList(data_captionhidden, "Value", "Text", model.data_captionhidden);
            ViewBag.data_endeasing     = new SelectList(data_easing, "Value", "Text", model.data_easing);
            return(View(model));
        }
Пример #10
0
 public ActionResult Edit([Bind(Include = "BrandID,BrandName,Image")] Brands brands, HttpPostedFileBase img)
 {
     if (ModelState.IsValid)
     {
         if (img != null && CheckContentImage.IsImage(img))
         {
             if (!string.IsNullOrEmpty(brands.Image))
             {
                 System.IO.File.Delete(Server.MapPath("/img/") + brands.Image);
             }
             string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
             img.SaveAs(Server.MapPath("/img/") + filename);
             brands.Image = filename;
         }
         db.Entry(brands).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brands));
 }
Пример #11
0
 public ActionResult Edit([Bind(Include = "PageID,PageTitle,PageContent,KeyWord,PageShortDiscription,ImageThumline,UserID,Vaziaat")] Pages pages, HttpPostedFileBase img)
 {
     if (ModelState.IsValid)
     {
         if (img != null && CheckContentImage.IsImage(img))
         {
             if (!pages.ImageThumline.Contains("nopic.jpg"))
             {
                 System.IO.File.Delete(Server.MapPath("/img/page/") + pages.ImageThumline);
             }
             string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
             img.SaveAs(Server.MapPath("/img/page/") + filename);
             pages.ImageThumline = filename;
         }
         db.Entry(pages).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserID = new SelectList(db.Userses, "UserID", "FullName", pages.UserID);
     return(View(pages));
 }
Пример #12
0
        public ActionResult Create([Bind(Include = "ProductID,UserID,ProductTypeId,Title,ShortDiscription,Text,PicThumbnail,KeyWord,Date,Vaziaat")] Product product, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/Products/") + filename);
                    ImageResizer nrResizer = new ImageResizer();
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/1000×1500/") + filename, 1000, 1500);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/192×288/") + filename, 192, 288);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/262×393/") + filename, 262, 393);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/thum/") + filename, 150, 150);

                    product.PicThumbnail = filename;
                }
                else
                {
                    product.PicThumbnail = "nopic.jpg";
                }

                product.UserID          = db.Userses.Where(p => p.UserName == User.Identity.Name).SingleOrDefault().UserID;
                product.Date            = DateTime.Now;
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductTypeId = new SelectList(db.ProductTypes, "ProductTypeId", "Title", product.ProductTypeId);
            ViewBag.UserID        = new SelectList(db.Userses, "UserID", "FullName", product.UserID);
            return(View(product));
        }
Пример #13
0
        public ActionResult Edit([Bind(Include = "ProductID,UserID,ProductTypeId,Title,ShortDiscription,Text,PicThumbnail,KeyWord,Date,Vaziaat")] Product product, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                if (img != null && CheckContentImage.IsImage(img))
                {
                    if (!product.PicThumbnail.Contains("nopic"))
                    {
                        System.IO.File.Delete(Server.MapPath("/img/Products/") + product.PicThumbnail);
                        System.IO.File.Delete(Server.MapPath("/img/Products/1000×1500/") + product.PicThumbnail);
                        System.IO.File.Delete(Server.MapPath("/img/Products/192×288/") + product.PicThumbnail);
                        System.IO.File.Delete(Server.MapPath("/img/Products/262×393/") + product.PicThumbnail);
                        System.IO.File.Delete(Server.MapPath("/img/Products/thum/") + product.PicThumbnail);
                    }
                    string filename = Guid.NewGuid() + Path.GetExtension(img.FileName);
                    img.SaveAs(Server.MapPath("/img/Products/") + filename);
                    ImageResizer nrResizer = new ImageResizer();
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/1000×1500/") + filename, 1000, 1500);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/192×288/") + filename, 192, 288);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/262×393/") + filename, 262, 393);
                    nrResizer.Resize(Server.MapPath("/img/Products/") + filename,
                                     Server.MapPath("/img/Products/thum/") + filename, 150, 150);

                    product.PicThumbnail = filename;
                }
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ProductTypeId = new SelectList(db.ProductTypes, "ProductTypeId", "Title", product.ProductTypeId);
            ViewBag.UserID        = new SelectList(db.Userses, "UserID", "FullName", product.UserID);
            return(View(product));
        }
Пример #14
0
        public ActionResult overviewsave(OverviewViewModel Model, HttpPostedFileBase logo, HttpPostedFileBase fivicon)
        {
            if (ModelState.IsValid)
            {
                xml.SavetoXml("siteSetting/siteDiscription", Model.SiteDiscription);
                xml.SavetoXml("siteSetting/siteName", Model.SiteName);
                xml.SavetoXml("siteSetting/sitekeywords", Model.SiteKeyWord);
                if (logo != null && CheckContentImage.IsImage(logo))
                {
                    if (!string.IsNullOrEmpty(xml.loadline("siteSetting/logo")))
                    {
                        System.IO.File.Delete(Server.MapPath("/img/") + xml.loadline("siteSetting/logo"));
                    }

                    string filename = Guid.NewGuid() + Path.GetExtension(logo.FileName);
                    xml.SavetoXml("siteSetting/logo", filename);
                    logo.SaveAs(Server.MapPath("/img/") + filename);
                }
                if (fivicon != null && CheckContentImage.IsImage(fivicon))
                {
                    if (!string.IsNullOrEmpty(xml.loadline("siteSetting/fivicon")))
                    {
                        System.IO.File.Delete(Server.MapPath("/img/") + xml.loadline("siteSetting/fivicon"));
                    }

                    string filename = Guid.NewGuid() + Path.GetExtension(fivicon.FileName);
                    xml.SavetoXml("siteSetting/fivicon", filename);
                    fivicon.SaveAs(Server.MapPath("/img/") + filename);
                }

                ViewBag.succrssm = true;
                return(Redirect("/Admin/Home/siteSetting"));
            }

            return(RedirectToAction("siteSetting"));
        }