Exemplo n.º 1
0
        public Result UpsertItem(ItemDto itemDto)
        {
            try
            {
                if (itemDto.Mode == EnumCrudMode.Create)
                {
                    ItemRepo.AddItem(itemDto);
                }
                else if (itemDto.Mode == EnumCrudMode.Update)
                {
                    ItemRepo.UpdateItem(itemDto);
                }
                else if (itemDto.Mode == EnumCrudMode.Delete)
                {
                    ItemRepo.DeleteItem(itemDto);
                }

                return(new Result()
                {
                    ResultCode = EnumResultCode.OK, Dto = itemDto
                });
            }
            catch (Exception ex)
            {
                return(new Result()
                {
                    ResultCode = EnumResultCode.Error, Details = ex.Message, Dto = itemDto
                });
            }
        }
Exemplo n.º 2
0
        private void DeleteItemAction()
        {
            var item = _viewmodel.SelectedItem;

            if (item == null)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show(_view, $"Delete Item \"{_viewmodel.SelectedItem.Name}\"?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            _itemRepo.DeleteItem(item.Id);

            var index = _viewmodel.Items.IndexOf(item);

            _viewmodel.SelectedZone.RemoveItem(item);
            if (_viewmodel.Items.Count > 0)
            {
                if (_viewmodel.Items.Count > index)
                {
                    _select(_viewmodel.Items[index]);
                }
                else
                {
                    _select(_viewmodel.Items.Last());
                }
            }
        }
Exemplo n.º 3
0
 public ActionResult DeleteItem(int id)
 {
     if (Request.IsAuthenticated)
     {
         string   errMsg   = "";
         ItemRepo itemRepo = new ItemRepo();
         itemRepo.DeleteItem(id, out errMsg);
         TempData["ItemActionMsg"] = errMsg;
         return(RedirectToAction("ItemManagement"));
     }
     else
     {
         return(RedirectToAction("Login", "Home"));
     }
 }
Exemplo n.º 4
0
 public ActionResult Delete(int?id)
 {
     db.DeleteItem((int)id, (User as CustomPrincipal).UserId, DateTime.Now);
     iu.DeleteAllItemUnitByItem((int)id, 0, DateTime.Now);
     return(RedirectToAction("Index"));
 }