public JsonResult Option(int?id) { var dao = new SingersDAO(); if (dao.Option(id)) { List <Singer> singers = db.Singers.Where(n => n.singer_bin == false).OrderBy(n => n.singer_name).ToList(); List <jSingers> list = singers.Select(n => new jSingers { singer_active = n.singer_active, singer_bin = n.singer_bin, singer_id = n.singer_id, singer_img = n.singer_img, singer_name = n.singer_name, singer_note = n.singer_note, user_id = n.user_id, singer_datecreate = n.singer_datecreate.Value.ToString("dd/MM/yyyy"), singer_dateupdate = n.singer_dateupdate.Value.ToString("dd/MM/yyyy"), singer_option = n.singer_option, }).ToList(); return(Json(list, JsonRequestBehavior.AllowGet)); } else { return(Json(null)); } }
//Hàm Xoá public JsonResult Deletesing(int?id) { var dao = new SingersDAO(); var j = new JsonAdminController(); if (dao.Delete(id)) { List <Singer> singers = db.Singers.Where(n => n.singer_bin == true).OrderBy(n => n.singer_name).ToList(); List <jSingers> list = singers.Select(n => new jSingers { singer_active = n.singer_active, singer_bin = n.singer_bin, singer_id = n.singer_id, singer_img = n.singer_img, singer_name = n.singer_name, singer_note = n.singer_note, singer_datecreate = n.singer_datecreate.Value.ToString("dd/MM/yyyy"), singer_dateupdate = n.singer_dateupdate.Value.ToString("dd/MM/yyyy"), }).ToList(); return(Json(list, JsonRequestBehavior.AllowGet)); } else { return(Json(null)); } }
public ActionResult Edit(Singer singer, HttpPostedFileBase IMG) { Singer sing = db.Singers.Find(singer.singer_id); singer.singer_active = sing.singer_active; singer.singer_bin = sing.singer_bin; singer.singer_datecreate = sing.singer_datecreate; singer.singer_dateupdate = DateTime.Now; singer.singer_name = sing.singer_name; singer.singer_note = sing.singer_note; singer.singer_option = sing.singer_option; singer.user_id = sing.user_id; var i = new ImagesController(); if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_SINGER, code); singer.singer_img = code + IMG.FileName; } else { singer.singer_img = sing.singer_img; } var dao = new SingersDAO(); if (dao.Edit(singer)) { return(Redirect("/Admin/SingersAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }
public ActionResult Add(Singer singer, HttpPostedFileBase IMG, string del) { //Cập nhật có thay đổi singer.singer_option = true; singer.singer_bin = false; //Kiem tra thay đổi value if (singer.singer_active != true && singer.singer_active != false) { singer.singer_active = false; } //Hinh ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_SINGER, code); singer.singer_img = code + IMG.FileName; } else { singer.singer_img = "notImg.png"; } var dao = new SingersDAO(); var j = new JsonAdminController(); if (dao.Add(singer)) { return(Redirect("/Admin/SingersAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }