Exemplo n.º 1
0
        public async Task <IActionResult> DeleteConfirmed(long id)
        {
            //var allowanceDetail = await _context.AllowanceDetails.FindAsync(id);
            //_context.AllowanceDetails.Remove(allowanceDetail);
            //await _context.SaveChangesAsync();
            var allowanceDetail = detailRepository.GetDelete(id);
            await detailRepository.Delete(allowanceDetail);

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
0
        public int DeleteOrder(DateTime orderD, string orderNo, bool isConfirmedDeleting)
        {
            var orderToRemove      = _orderRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo).FirstOrDefault();
            var containerToRemoves = _containerRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo);
            var dispatchToRemoves  = _dispatchRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo);

            //checking Order's Dispatches Status before delete
            var isDeleteOder = IsDeleteOrder(containerToRemoves, dispatchToRemoves);

            //The order will not be deleted with Level.NotDeleted and Level.NotDeleteAndWarning but isDeletedWithoutWarning is false
            if (isDeleteOder == Convert.ToInt32(DeleteLevel.NotDeleted) ||
                (isDeleteOder == Convert.ToInt32(DeleteLevel.NotDeletedAndWarning) && !isConfirmedDeleting) ||
                (isDeleteOder == Convert.ToInt32(DeleteLevel.Deleted) && !isConfirmedDeleting))
            {
                return(isDeleteOder);
            }

            //Process deleting Order
            var expenseDs = _expenseDetailRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo);

            if (expenseDs != null)
            {
                foreach (var expenseD in expenseDs)
                {
                    _expenseDetailRepository.Delete(expenseD);
                }
            }

            var surchargeDs = _surchargeDetailRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo);

            if (surchargeDs != null)
            {
                foreach (var surchargeD in surchargeDs)
                {
                    _surchargeDetailRepository.Delete(surchargeD);
                }
            }

            var allowanceDs = _allowanceDetailRepository.Query(p => p.OrderD == orderD && p.OrderNo == orderNo);

            if (allowanceDs != null)
            {
                foreach (var allowanceD in allowanceDs)
                {
                    _allowanceDetailRepository.Delete(allowanceD);
                }
            }

            if (dispatchToRemoves != null)
            {
                foreach (var dispatchToRemove in dispatchToRemoves)
                {
                    _dispatchRepository.Delete(dispatchToRemove);
                }
            }
            if (containerToRemoves != null)
            {
                foreach (var containerToRemove in containerToRemoves)
                {
                    _containerRepository.Delete(containerToRemove);
                }
            }
            if (orderToRemove != null)
            {
                _orderRepository.Delete(orderToRemove);
            }
            SaveOrder();
            return(isDeleteOder);
        }