public ActionResult Edit(tbl_BaiHat nv)
 {
     if (ModelState.IsValid)
     {
         var path = (string)null;
         if (Request.Files.Count > 0)
         {
             var file = Request.Files[0];
             if (file != null && file.ContentLength > 0)
             {
                 var fileName = Path.GetFileName(file.FileName);
                 path = Path.Combine(Server.MapPath("~/asset/client/Audio_Video/Audio/TinTuc"), fileName);
                 file.SaveAs(path);
                 nv.url_BaiHat = path;
             }
         }
         var dao    = new BaiHatDao();
         var result = dao.Update(nv);
         if (result)
         {
             return(RedirectToAction("Index", "BaiHat"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật nhân viên thành công!");
         }
     }
     return(View());
 }
 public ActionResult Create(tbl_BaiHat obj)
 {
     if (!ModelState.IsValid)
     {
         obj.LuotNghe = 0;
         obj.LuotTai  = 0;
         var path = (string)null;
         var dao  = new BaiHatDao();
         if (Request.Files.Count > 0)
         {
             var file = Request.Files[0];
             if (file != null && file.ContentLength > 0)
             {
                 var fileName = Path.GetFileName(file.FileName);
                 path = Path.Combine(Server.MapPath("~/asset/client/Audio_Video/Audio/BaiHat"), fileName);
                 file.SaveAs(path);
             }
         }
         obj.url_BaiHat = path;
         long id = dao.Insert(obj);
         if (id > 0)
         {
             return(RedirectToAction("Index", "TinTuc"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm nhân viên thành công!");
         }
     }
     return(RedirectToAction("Index"));
 }
Beispiel #3
0
        public void Update_LuotNghe(long id)
        {
            tbl_BaiHat obj = new tbl_BaiHat();

            obj = db.tbl_BaiHat.SingleOrDefault(e => e.Id == id);
            if (obj.LuotNghe == null)
            {
                obj.LuotNghe = 1;
            }
            else
            {
                obj.LuotNghe = obj.LuotNghe + 1;
            }
            db.SaveChanges();
        }
Beispiel #4
0
 public bool Update(tbl_BaiHat entity)
 {
     try
     {
         var obj = db.tbl_BaiHat.Find(entity.Id);
         obj.TenBaiHat  = entity.TenBaiHat;
         obj.url_BaiHat = entity.url_BaiHat;
         obj.url_Image  = entity.url_Image;
         obj.LuotNghe   = entity.LuotNghe;
         obj.LuotTai    = entity.LuotTai;
         obj.Active     = entity.Active;
         obj.Id_TheLoai = entity.Id_TheLoai;
         obj.Id_CaSi    = entity.Id_CaSi;
         obj.Id_ChuDe   = entity.Id_ChuDe;
         obj.Id_Album   = entity.Id_Album;
         obj.ID_NhacSi  = entity.ID_NhacSi;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #5
0
 public long Insert(tbl_BaiHat entity)
 {
     db.tbl_BaiHat.Add(entity);
     db.SaveChanges();
     return(entity.Id);
 }