public ActionResult Add(Music.Model.EF.Author author, HttpPostedFileBase IMG, string del) { author.author_bin = false; if (author.author_active != true && author.author_active != false) { author.author_active = false; } //Chèn ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new FilesController(); img.AddImages(IMG, Common.Link.IMG_AUTHOR, code); author.author_img = code + IMG.FileName; } else { author.author_img = "notImg.png"; } if (authorsDAO.Add(author)) { return(Redirect("/Admin/AuthorsAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }
public ActionResult Edit(Music.Model.EF.Author author, HttpPostedFileBase IMG, string del) { Author au = db.Authors.Find(author.author_id); author.author_bin = false; author.author_datecreate = au.author_datecreate; author.author_dateupdate = DateTime.Now; author.author_active = true; if (author.author_active != true && author.author_active != false) { author.author_active = false; } //Chèn ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new FilesController(); img.AddImages(IMG, Common.Link.IMG_AUTHOR, code); author.author_img = code + IMG.FileName; } else { author.author_img = au.author_img; } if (authorsDAO.Edit(author)) { return(Redirect("/Admin/AuthorsAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }