Exemplo n.º 1
0
        public void Update(OrderDTO order)
        {
            //16.  Klientni qarzi bor edi uni order kirib qarzni togirladi lekin klient listda qarz bor deb korsatyapti klientni double click qilsa ichiga kirgandan qarzi yoq korsatyapti
            // WAS FIXED IN PREVIOUS COMMIT BUT CLIENT RECIEVED EARLIER VERSION WITH BUG. FIXED DOUBLE TESTED
            var orderExisting = new OrderDalFacade().GetClientOrder(order.Id);

            new OrderDalFacade().Update(order);
            var amount = (orderExisting.OverallPrice - (orderExisting.PaymentByTransfer + orderExisting.PaymentByCard + orderExisting.PaymentByCash))
                         - (order.OverallPrice - (order.PaymentByTransfer + order.PaymentByCard + order.PaymentByCash));
            var sales = new SaleBL().GetOrderSale(order.Id);

            sales.RemoveAll(x => order.Sales.Exists(y => y.Id == x.Id));
            foreach (var deletedSale in sales)
            {
                new SaleBL().Delete(deletedSale.Id);
            }

            if (order.ClientId == null || order.ClientId == 0)
            {
                return;
            }
            var debtorCreditor = new DebtorCreditorDTO()
            {
                ClientId = order.ClientId,
                Amount   = amount
            };

            new DebtorCreditorsBL().UpdateDebtorCreditorPart(debtorCreditor);
        }
Exemplo n.º 2
0
        public void Add(OrderDTO order)
        {
            if (order.ClientId == 0)
            {
                order.ClientId = null;
            }
            new ProductStockBL().UpdateProductStocks(order);
            new OrderDalFacade().Add(order);
            //
            if (order.ClientId == null || order.ClientId == 0)
            {
                return;
            }

            // in order to calculate client debt, we substract all the paid money from the order's overall price
            var debtAmount = -1 * (order.OverallPrice - (order.PaymentByTransfer + order.PaymentByCard + order.PaymentByCash));

            if (debtAmount == 0)
            {
                return;
            }

            var creditorDebtor = new DebtorCreditorDTO()
            {
                ClientId = order.ClientId,
                ///!!! very Important initially it was only paymentByTransfer, by illogical request all payment types are addded to count debt
                Amount = debtAmount
            };

            new DebtorCreditorsBL().UpdateDebtorCreditorPart(creditorDebtor);
        }
        public void Update(DebtorCreditorDTO dto)
        {
            var income = (from c in db.DebtorCreditors where c.Id == dto.Id select c).FirstOrDefault();

            income.Amount      = dto.Amount;
            income.UpdatedDate = dto.UpdatedDate;
            income.isDebtor    = dto.IsDebtor;

            db.SubmitChanges();
        }
Exemplo n.º 4
0
 public HttpResponseMessage Add(DebtorCreditorDTO dto)
 {
     try
     {
         new DebtorCreditorsBL().Add(dto);
         return(Request.CreateResponse(HttpStatusCode.OK, true));
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, false));
     }
 }
        public void Add(DebtorCreditorDTO dto)
        {
            var debtorCreditor = new DebtorCreditor()
            {
                ClientId    = dto.ClientId.Value,
                Amount      = dto.Amount,
                CreatedDate = dto.CreatedDate,
                UpdatedDate = dto.UpdatedDate,
                isDebtor    = dto.IsDebtor
            };

            db.DebtorCreditors.InsertOnSubmit(debtorCreditor);
            db.SubmitChanges();
        }