public async Task <int> AddBillCollectionAsync(BillCollection billCollection)
        {
            var context = this._billSplitterContext;


            var actualBillCollection = new BillCollection
            {
                Date  = billCollection.Date.Date,
                Bills = new List <Bill>(billCollection.Bills.Select(bill => new Bill
                {
                    PersonId    = bill.PersonId,
                    SupplierId  = bill.SupplierId,
                    TotalAmount = bill.TotalAmount,
                    BillDate    = bill.BillDate,
                    Comment     = bill.Comment,

                    Splits = new List <Split>(bill.Splits.Select(split => new Split
                    {
                        PersonId     = split.PersonId,
                        SplitAmount  = split.SplitAmount,
                        SplitPercent = split.SplitPercent,
                    }))
                }))
            };

            await context.BillCollections.AddAsync(actualBillCollection);

            return(await context.SaveChangesAsync());
        }
Beispiel #2
0
        public async Task <ActionResult> SaveAsync(int id, [FromBody] BillCollection billCollection)
        {
            try
            {
                if (id == billCollection.BillCollectionId)
                {
                    var result = await this._billService.UpdateBillCollectionAsync(billCollection);

                    if (result > 0)
                    {
                        return(this.Ok());
                    }
                    else
                    {
                        return(this.BadRequest("No change was made"));
                    }
                }
                else
                {
                    return(this.BadRequest("Bad id"));
                }
            }
            catch (Exception ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
Beispiel #3
0
        private void LoadSelectedBill()
        {
            lblHiddenBillId.Text = "";
            loadSelectedBill     = new BillCollection();
            loadSelectedBill.LoadBillWithStdIdFromDb(selectedId);

            foreach (var popBill in loadSelectedBill.pubBillCollect)
            {
                lblHiddenBillId.Text = popBill.Bill_Id.ToString();
                lblTotalAmount.Text  = popBill.Bill_TotalAmount.ToString();
                lblDiscount.Text     = popBill.Bill_Discount.ToString();
                lblFinalAmount.Text  = popBill.Bill_FinalAmount.ToString();
                lblPaymentMade.Text  = popBill.Bill_PaymentMade.ToString();
                lblSemester.Text     = popBill.Bill_Semester;
                lblBalance.Text      = popBill.Bill_Balance.ToString();
                lblSchoolYr.Text     = popBill.Bill_SchoolYear;
            }
        }
Beispiel #4
0
        public async Task <ActionResult> SaveAsync([FromBody] BillCollection billCollection)
        {
            try
            {
                var result = await this._billService.AddBillCollectionAsync(billCollection);

                if (result > 0)
                {
                    return(this.Ok());
                }
                else
                {
                    return(this.BadRequest("No change was made"));
                }
            }
            catch (Exception ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
        private void LoadSelectedBill()
        {
            billId           = 0;
            loadSelectedBill = new BillCollection();
            loadSelectedBill.LoadBillWithStdIdFromDb(selectedId);

            foreach (var popBill in loadSelectedBill.pubBillCollect)
            {
                billId             = popBill.Bill_Id;
                txtAmount.Text     = popBill.Bill_TotalAmount.ToString();
                txtDiscount.Text   = popBill.Bill_Discount.ToString();
                txtFinal.Text      = popBill.Bill_FinalAmount.ToString();
                txtPayMade.Text    = popBill.Bill_PaymentMade.ToString();
                txtSemester.Text   = popBill.Bill_Semester;
                txtBalance.Text    = popBill.Bill_Balance.ToString();
                txtSchoolYear.Text = popBill.Bill_SchoolYear;
                billStatus         = popBill.Bill_Status;
                billDueDate        = popBill.Bill_DueDate;
                billDatePaid       = popBill.Bill_DatePaid;
            }
        }
        public async Task <int> UpdateBillCollectionAsync(BillCollection billCollection)
        {
            var context = this._billSplitterContext;

            var actualBillCollection = await this.GetBillCollectionAsync(billCollection.BillCollectionId);

            actualBillCollection.Date = billCollection.Date.Date;

            actualBillCollection.Bills.Update(
                billCollection.Bills,
                b => new { b.BillCollectionId, b.BillId },
                b => new { b.BillCollectionId, b.BillId },
                (b, k) => b,
                (src, dest) =>
            {
                dest.PersonId    = src.PersonId;
                dest.SupplierId  = src.SupplierId;
                dest.TotalAmount = src.TotalAmount;
                dest.BillDate    = src.BillDate;
                dest.Comment     = src.Comment;

                dest.Splits.Update(
                    src.Splits,
                    s => new { s.BillId, s.BillCollectionId, s.PersonId },
                    s => new { s.BillId, s.BillCollectionId, s.PersonId },
                    (s, k) => s,
                    (src1, dest1) =>
                {
                    dest1.SplitAmount  = src1.SplitAmount;
                    dest1.SplitPercent = src1.SplitPercent;
                });
            });

            context.BillCollections.Update(actualBillCollection);
            return(await context.SaveChangesAsync());
        }
        private void LoadStdBill()
        {
            loadBillData = new BillCollection();
            loadBillData.LoadBillWithStdIdFromDb(Int32.Parse(LoginUser.stdLogStudentId));

            foreach (var popBill in loadBillData.pubBillCollect)
            {
                if (DateTime.Parse(popBill.Bill_DueDate) < DateTime.Today)
                {
                    var setOldManage = new BillManager();
                    setOldManage.SetTuitionToOld(popBill.Bill_Id);
                    SetOldPart();
                    stop = true;
                    return;
                }
                lblTotalTuitionContainer.Text     = popBill.Bill_FinalAmount.ToString();
                lblDiscountContainer.Text         = $"{popBill.Bill_Discount.ToString()}%";
                lblTotalBalanceContainer.Text     = popBill.Bill_Balance.ToString();
                lblTotalPaymentMadeContainer.Text = popBill.Bill_PaymentMade.ToString();
                lblFullPaidDateContainer.Text     = popBill.Bill_DatePaid.ToString();
                lblTuitionDueDateContainer.Text   = popBill.Bill_DueDate.ToString();
                billId = popBill.Bill_Id;
            }
        }