public ActionResult DeleteConfirmed(int id) { t_download t_download = db.t_download.Find(id); db.t_download.Remove(t_download); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int id = 0) { t_download t_download = db.t_download.Find(id); if (t_download == null) { return(HttpNotFound()); } return(View(t_download)); }
public ActionResult Edit(int id, admin.Models.DownloadCreate t_download) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { t_download download = db.t_download.Find(id); download.download_date = DateTime.Now; download.download_desc = t_download.download_desc; download.download_title = t_download.download_title; download.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); if (t_download.dokumen != null) { if (t_download.dokumen.ContentLength < 3048000) { var fileName = Path.GetFileName(t_download.dokumen.FileName); var ex = Path.GetExtension(fileName); if (ex == ".pdf" || ex == ".xls" || ex == ".xlsx" || ex == ".doc" || ex == ".docx" || ex == ".ppt" || ex == ".pptx") { var path = Path.Combine(Server.MapPath("~/Content/Document"), fileName); t_download.dokumen.SaveAs(path); download.download_path = "~/Content/Document/" + fileName; } else { ModelState.AddModelError("", "File harus berformat (.pdf/.ppt/.pptx/.xls/.xlsx/.doc/.docx)"); return(View(t_download)); } } else { ModelState.AddModelError("", "Ukuran file tidak boleh lebih dari 3 MB"); return(View(t_download)); } } db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_download)); }
public ActionResult Edit(int id = 0) { t_download t_download = db.t_download.Find(id); var download = (from table in db.t_download where table.download_id == id select new admin.Models.DownloadUpdate { download_id = table.download_id, download_date = table.download_date, download_desc = table.download_desc, download_title = table.download_title, user_id = table.user_id, dokumen = table.download_path }).FirstOrDefault(); if (download == null) { return(HttpNotFound()); } return(View(download)); }