public ActionResult AddImages(Slider objslid, HttpPostedFileBase file) { if (isFileValid(file)) { string fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Images"), fileName); string[] file_name = fileName.Split('.'); file.SaveAs(path); } //var path = Path.Combine(Server.MapPath("~/Images/")); //file.SaveAs(path); //string fileName = file.FileName; string ImageName = fileName.Split('.')[0].ToString(); string ImagePath = "Images/" + fileName; objSlider.ImageName = ImageName; objSlider.ImagePath = ImagePath; db.Sliders.Add(objSlider); db.SaveChanges(); } else { ViewBag.path = "Invalid Dimensions"; } objSlider.slidList = db.Sliders.ToList(); return(View("Index", objSlider.slidList)); }
public ActionResult Create([Bind(Include = "Id,Title,Description,Date,status")] News news) { if (ModelState.IsValid) { db.News.Add(news); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(news)); }
public ActionResult Create([Bind(Include = "Id,Date,Note,Status")] Event @event) { if (ModelState.IsValid) { db.Events.Add(@event); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(@event)); }
public ActionResult Save(News objNews) { ViewBag.IsSaved = false; db = new DenimEntities(); if (ModelState.IsValid) { try { obj.Title = objNews.Title; obj.Date = objNews.Date; obj.Description = objNews.Description; db.News.Add(obj); db.SaveChanges(); ModelState.Clear(); ViewBag.IsSaved = true; } catch (Exception) { } } News objEvents = new News(); objEvents.NewsList = db.News.ToList(); return(View("Index", objEvents.NewsList)); }
public ActionResult Delete(int?id) { if (!string.IsNullOrEmpty(id.ToString())) { db = new DenimEntities(); try { if (!string.IsNullOrWhiteSpace(Convert.ToString(id))) { News obj = db.News.Find(id); db.News.Remove(obj); db.SaveChanges(); } } catch { } News objEvents = new News(); objEvents.NewsList = db.News.ToList(); return(View("Index", objEvents.NewsList)); } else { return(View("~/Areas/Admin/Views/Shared/Error.cshtml")); } }
public ActionResult Save(Event objEvnt) { ViewBag.IsSaved = false; db = new DenimEntities(); if (ModelState.IsValid) { try { objEvent.Note = objEvnt.Note; objEvent.Date = objEvnt.Date; objEvent.Status = objEvnt.Status; db.Events.Add(objEvent); db.SaveChanges(); ModelState.Clear(); ViewBag.IsSaved = true; } catch (Exception) { } } Event objEvents = new Event(); objEvents.eventList = db.Events.ToList(); return(View("Index", objEvents.eventList)); }
public ActionResult Update(Gallery objgal, int id) { try { db = new DenimEntities(); Gallery gal = db.Galleries.Find(id); gal.EventId = objgal.EventId; gal.ImageName = objgal.ImageName; db.Entry(gal); db.SaveChanges(); } catch { } Gallery objEvents = new Gallery(); objEvents.imageList = db.Galleries.ToList(); return(View("Index", objEvents.imageList)); //objGallery = new Gallery(); //ViewBag.Event = new SelectList(db.Events, "Id", "Note", objGallery.EventId); //return View(); }
public ActionResult AddFiles(Denim.Models.File obj, HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var path = Path.Combine(Server.MapPath("~/Files/")); //file.SaveAs(path); string fileName = file.FileName; string ImageName = fileName.Split('.')[0].ToString(); string ImagePath = "~/Files/" + fileName; objFile.FileName = ImageName; objFile.FilePath = ImagePath; db.Files.Add(objFile); db.SaveChanges(); } Denim.Models.File objEvents = new Denim.Models.File(); objFile.FileList = db.Files.ToList(); return(View("Index", objFile.FileList)); }
public ActionResult DeleteGalleryImage(int id) { if (!string.IsNullOrEmpty(id.ToString())) { db = new DenimEntities(); Gallery objGallery = db.Galleries.Find(id); db.Galleries.Remove(objGallery); db.SaveChanges(); objGallery.imageList = db.Galleries.ToList(); return(View("Index", objGallery.imageList)); } else { return(View("~/Areas/Admin/Views/Shared/Error.cshtml")); } }
public ActionResult Update(News objEvnt, int id) { try { db = new DenimEntities(); News obj = db.News.Find(id); obj.Title = objEvnt.Title; obj.Date = objEvnt.Date; obj.Description = objEvnt.Description; db.Entry(obj); db.SaveChanges(); } catch { } obj.NewsList = db.News.ToList(); return(View("Index", obj.NewsList)); }
public ActionResult Update(Event objEvnt, int id) { try { db = new DenimEntities(); Event objEvent = db.Events.Find(id); objEvent.Note = objEvnt.Note; objEvent.Date = objEvnt.Date; objEvent.Status = objEvnt.Status; db.Entry(objEvent); db.SaveChanges(); } catch { } Event objEvents = new Event(); objEvents.eventList = db.Events.ToList(); return(View("Index", objEvents.eventList)); }
public ActionResult SaveGallery(Gallery objGal, HttpPostedFileBase file) { ViewBag.IsSaved = false; db = new DenimEntities(); if (ModelState.IsValid) { try { var fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Gallery/Events"), fileName); string[] file_name = fileName.Split('.'); file.SaveAs(path); } string ImageName = fileName.Split('.')[0].ToString(); string ImagePath = "Gallery/Events/" + fileName; objGallery = new Gallery(); objGallery.EventId = objGal.EventId; objGallery.ImageName = ImageName; objGallery.ImagePath = ImagePath; db.Galleries.Add(objGallery); db.SaveChanges(); ModelState.Clear(); ViewBag.IsSaved = true; } catch (Exception) { } } ViewBag.EventId = new SelectList(db.Events, "Id", "Note"); objGallery.imageList = db.Galleries.ToList(); return(View("Index", objGallery.imageList)); }