コード例 #1
0
ファイル: LoaisController.cs プロジェクト: TranDuc1991/DucTV
        public IActionResult UpdateLoaiId(int id, LoaiModel model)
        {
            var loai = _context.Loais.SingleOrDefault(lo => lo.MaLoai == id);

            if (loai != null)
            {
                loai.TenLoai = model.TenLoai;
                _context.SaveChanges();
                return(Ok(loai));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #2
0
ファイル: LoaisController.cs プロジェクト: TranDuc1991/DucTV
 public IActionResult CreateNew(LoaiModel model)
 {
     try
     {
         var loai = new Loai
         {
             TenLoai = model.TenLoai
         };
         _context.Add(loai);
         _context.SaveChanges();
         return(Ok(loai));
     }catch
     {
         return(BadRequest());
     }
 }
コード例 #3
0
        public bool Update(LoaiModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_loai_update",
                                                                              "@maloai", model.ma_loai,
                                                                              "@tenloai", model.ten_loai);
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
 public bool Create(LoaiModel model)
 {
     return(_res.Create(model));
 }
コード例 #5
0
 public bool Update(LoaiModel model)
 {
     return(_res.Update(model));
 }
コード例 #6
0
 public LoaiModel UpdateLoai([FromBody] LoaiModel model)
 {
     _itemBusiness.Update(model);
     return(model);
 }
コード例 #7
0
 public LoaiModel CreateLoai([FromBody] LoaiModel model)
 {
     model.ma_loai = Guid.NewGuid().ToString();
     _itemBusiness.Create(model);
     return(model);
 }
コード例 #8
0
 public LoaiModel CreateItem([FromBody] LoaiModel model)
 {
     _itemBusiness.Create(model);
     return(model);
 }