public ActionResult Add(Music.Model.EF.Singer singer, HttpPostedFileBase IMG, string del)
        {
            singer.singer_bin        = false;
            singer.singer_dateupdate = DateTime.Now;

            if (singer.singer_active != true && singer.singer_active != false)
            {
                singer.singer_active = false;
            }

            //Chèn ảnh
            if (IMG != null)
            {
                var code = Guid.NewGuid().ToString();
                var img  = new FilesController();
                img.AddImages(IMG, Common.Link.IMG_SINGER, code);
                singer.singer_img = code + IMG.FileName;
            }
            else
            {
                singer.singer_img = "notImg.png";
            }

            if (singersDAO.Add(singer))
            {
                return(Redirect("/Admin/SingersAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }
Beispiel #2
0
 public ActionResult ChangeActive(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Music.Model.EF.Singer singer = db.Singers.Find(id);
     if (singer == null)
     {
         return(HttpNotFound());
     }
     db.Singers.Find(id).singer_active = !db.Singers.Find(id).singer_active;
     db.SaveChanges();
     return(Json(true, JsonRequestBehavior.AllowGet));
 }