Пример #1
0
        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
 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);
 }