public async Task <ActionResult> Edit([Bind(Include = "IDBanner,Banner,FilmName,Description")] TSql_Banner tSql_Banner, HttpPostedFileBase fileimg) { if (ModelState.IsValid) { var img = Path.GetFileName(fileimg.FileName); var pathimg = Path.Combine(Server.MapPath("~/Content/images"), img); if (fileimg == null) { ViewBag.Img = "Chose images"; return(View()); } else if (System.IO.File.Exists(pathimg)) { ViewBag.Img = "Images had exists"; } else { fileimg.SaveAs(pathimg); } tSql_Banner.Banner = fileimg.FileName; db.Entry(tSql_Banner).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tSql_Banner)); }
// POST: Admin/TSql_Banner/Delete/5 public async Task <ActionResult> DeleteConfirmed(int id) { TSql_Banner tSql_Banner = await db.TSql_Banner.FindAsync(id); db.TSql_Banner.Remove(tSql_Banner); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "IDBanner,Banner,FilmName,Description")] TSql_Banner tSql_Banner, HttpPostedFileBase fileimg) { if (ModelState.IsValid) { db.TSql_Banner.Add(tSql_Banner); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tSql_Banner)); }
// GET: Admin/TSql_Banner/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSql_Banner tSql_Banner = await db.TSql_Banner.FindAsync(id); if (tSql_Banner == null) { return(HttpNotFound()); } return(View(tSql_Banner)); }