public JsonResult Restore(int?id) { var dao = new AuthorsDAO(); if (dao.Restore(id)) { List <Author> authors = db.Authors.Where(n => n.author_bin == true).OrderBy(n => n.author_name).ToList(); List <jAuthors> list = authors.Select(n => new jAuthors { author_active = n.author_active, author_bin = n.author_bin, author_datecreate = n.author_datecreate.Value.ToString("dd/MM/yyyy"), author_dateupdate = n.author_dateupdate.Value.ToString("dd/MM/yyyy"), author_id = n.author_id, author_img = n.author_img, author_name = n.author_name, author_note = n.author_note }).ToList(); return(Json(list, JsonRequestBehavior.AllowGet)); } else { return(Json(null)); } }
public ActionResult Add(Author author, HttpPostedFileBase IMG, string del) { //Cập nhật có thay đổi author.author_option = true; author.author_bin = false; //Kiem tra thay đổi value if (author.author_active != true && author.author_active != false) { author.author_active = false; } //Hinh ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_AUTHOR, code); author.author_img = code + IMG.FileName; } else { author.author_img = "notImg.png"; } var dao = new AuthorsDAO(); var j = new JsonAdminController(); if (dao.Add(author)) { return(Redirect("/Admin/AuthorsAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }
public ActionResult Edit(Author author, HttpPostedFileBase IMG) { Author au = db.Authors.Find(author.author_id); author.author_active = au.author_active; author.author_datecreate = au.author_datecreate; author.author_dateupdate = DateTime.Now; author.author_bin = au.author_bin; author.author_option = au.author_option; author.user_id = au.user_id; var i = new ImagesController(); if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_AUTHOR, code); author.author_img = code + IMG.FileName; } else { author.author_img = au.author_img; } var dao = new AuthorsDAO(); if (dao.Edit(author)) { return(Redirect("/Admin/authorsAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }