public ActionResult tabledata(carousel data) { return(Redirect("tabledata")); }
public ActionResult service(service data) { var login = Convert.ToInt16(Session["login"]); if (data.ID > 0) { var conf = db.services.Where(i => i.ID == data.ID).SingleOrDefault(); if (conf != null) { conf.UPDATED_DATE = DateTime.Now; conf.UPDATED_BY = login; if (data.SERVICE_TYPE != null) { conf.SERVICE_TYPE = data.SERVICE_TYPE; } if (data.IMAGE != null) { Models.carousel imgs = new carousel(); imgs.IMAGE = data.IMAGE; HttpFileCollectionBase file = Request.Files; for (int i = 0; i < file.Count; i++) { HttpPostedFileBase Image = file[i]; var filename = ""; if (Image != null) { filename = Path.GetFileName(Image.FileName); var path3 = Path.Combine(Server.MapPath("~/images"), filename); Image.SaveAs(path3); data.IMAGE = filename; conf.IMAGE = data.IMAGE; } } } conf.SERVICE_NAME = data.SERVICE_NAME; conf.DESCRIPTION = data.DESCRIPTION; if (data.IS_ACTIVE != null) { conf.IS_ACTIVE = data.IS_ACTIVE; } db.SaveChanges(); } } else { if (data.IMAGE != null) { Models.news imgs = new news(); imgs.IMAGE = data.IMAGE; HttpFileCollectionBase file = Request.Files; for (int i = 0; i < file.Count; i++) { HttpPostedFileBase Image = file[i]; var filename = ""; if (Image != null) { filename = Path.GetFileName(Image.FileName); var path3 = Path.Combine(Server.MapPath("~/images"), filename); Image.SaveAs(path3); data.IMAGE = filename; db.SaveChanges(); } } } data.CREATED_DATE = DateTime.Now; data.CREATED_BY = login; data.IS_DELETED = false; var time = db.services.Add(data); db.SaveChanges(); } return(RedirectToAction("service")); }