Пример #1
0
        public static void Update(RepaymentsDTO repayment)
        {
            db         DB           = new db();
            Repayments repaymentDal = DB.Repayments.FirstOrDefault(r => r.RepaymentId == repayment.Id);

            if (repayment.NameStatus == "performed" && repaymentDal.NameStatus != "performed")
            {
                FundBL.AddBalance(repayment.Amount);
            }
            repaymentDal.Amount     = repayment.Amount;
            repaymentDal.NameStatus = repayment.NameStatus;
            repaymentDal.Date       = repayment.Date;
            // repaymentDal.remark= repayment.Remark;
            DB.SaveChanges();
        }
Пример #2
0
        public static void Updete(WithdrawalsDTO withdrawalDTO)
        {
            db          DB         = new db();
            withdrawing withdrawal = DB.Withdrawing.FirstOrDefault(w => w.Id == withdrawalDTO.Id);

            //if it changed to Approved
            if (withdrawal.NameStatus != "performed" && withdrawalDTO.Status == "performed")
            {
                FundBL.Subtract_Balance(withdrawalDTO.Amount, withdrawalDTO.FundId);
            }
            else
            {
                //if it was performed and changed to canceled
                if (withdrawal.NameStatus == "performed" && withdrawalDTO.Status == "canceled")
                {
                    FundBL.AddBalance(withdrawalDTO.Amount, withdrawalDTO.FundId);
                }
            }
            withdrawal.Amount = withdrawalDTO.Amount;
            withdrawal.Date   = withdrawalDTO.Date;
            // withdrawal.paymentMethod = withdrawalDTO.PaymentMethod;
            withdrawal.NameStatus = withdrawalDTO.Status;
            DB.SaveChanges();
        }