Пример #1
0
 public async Task <IActionResult> AddItem(ItemForInsertDto forInsert)
 {
     try
     {
         var objInsert = _mapper.Map <Item>(forInsert);
         _repo.Add(objInsert);
         if (await _repo.SaveAll())
         {
             return(NoContent());
         }
         return(StatusCode(201));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public async Task <IActionResult> UpdateItem(int ItemId, ItemForInsertDto forUpdate)
        {
            try
            {
                var row = await _repo.GetItemByItemId(ItemId);

                _mapper.Map(forUpdate, row);
                if (await _repo.SaveAll())
                {
                    return(NoContent());
                }
                return(StatusCode(201));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }