예제 #1
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                throw new Exception("Not Found");
            }
            Commodity commodity = iCommodityService.Find <Commodity>(id ?? -1);

            if (commodity == null)
            {
                throw new Exception("Not Found");
            }
            else
            {
                iCommodityService.Delete(commodity);
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public void Delete(int id)
        {
            var item = this.CommodityService.GetById(id);

            if (item != null)
            {
                CommodityService.Delete(item);

                Logger.LogWithSerialNo(LogTypes.CommodityDelete, SerialNoHelper.Create(), item.CommodityId, item.Name);
                AddMessage("delete.success", item.Name);
            }
        }
예제 #3
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var entity = await _commodityService.GetbyIdAsync(id);

                if (entity == null)
                {
                    //_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
                    return(NotFound());
                }

                await _commodityService.Delete(entity);

                return(Ok());

                //return NoContent();
            }
            catch (Exception ex)
            {
                //_logger.LogError($"Something went wrong inside DeleteOwner action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
예제 #4
0
        public async Task <IActionResult> Delete(int id)
        {
            var response = await _commodityService.Delete(id);

            return(Ok(response));
        }