Пример #1
0
 public ActionResult edit(int ID,string title,string imagepath,string status,string path)
 {
     SliderImage slider = new SliderImage();
        var images = Request.Files[0];
        if (string.IsNullOrEmpty(images.FileName))
        {
        slider.ID = ID;
        slider.Title = title;
        slider.ImagePath = path;
        slider.Status = (string.IsNullOrEmpty(status) ? false : true);
        SliderImages.updateimage(slider);
        return View("index");
        }
        else if (images.ContentType == "image/jpeg")
        {
        string pathh = "~/images/slider/" + DateTime.Now.Millisecond.ToString() + images.FileName;
        images.SaveAs(Server.MapPath(pathh));
        slider.ID = ID;
        slider.Title = title;
        slider.ImagePath = pathh;
        slider.Status = ((string.IsNullOrEmpty(status)) ? false : true);
        SliderImages.updateimage(slider);
        return View("index");
        }
        else
        return View(model:"عکس غیر مجاز است");
 }
Пример #2
0
 public static void updateimage(SliderImage slider)
 {
     DB sample = new DB();
     SliderImage oldimage = sample.SliderImages.Single(item => item.ID == slider.ID);
     oldimage.Title = slider.Title;
     oldimage.ImagePath = slider.ImagePath;
     oldimage.Status = slider.Status;
     sample.SaveChanges();
 }
Пример #3
0
 public static void Addimages(SliderImage slider)
 {
     DB sample = new DB();
     sample.SliderImages.Add(slider);
     sample.SaveChanges();
 }