Example #1
0
        public void TestModelCustomerId()
        {
            RequestModel requestModel = new RequestModel()
            {
                Id        = 1,
                StartDate = new DateTime(2015, 1, 1),
                EndDate   = new DateTime(2018, 1, 1)
            };

            InvoiceReviewModel model = set.InvoiceReview.Report(requestModel);

            Assert.AreEqual(model.CustomerId, 1);
        }
Example #2
0
        public void TestModelGrandTotal()
        {
            RequestModel requestModel = new RequestModel()
            {
                Id        = 1,
                StartDate = new DateTime(2015, 1, 1),
                EndDate   = new DateTime(2018, 1, 1)
            };

            InvoiceReviewModel model = set.InvoiceReview.Report(requestModel);

            double sum = 0;

            foreach (var item in model.Invoices)
            {
                sum += item.InvoiceTotal;
            }
            Assert.AreEqual(model.GrandTotal, sum);
        }
Example #3
0
        public InvoiceReviewModel Report(RequestModel Request)
        {
            List <Invoice> Invoices = UnitOfWork.Invoices.Get().Where(x => x.Date >= Request.StartDate &&
                                                                      x.Date <= Request.EndDate &&
                                                                      x.Customer.Id == Request.Id).ToList();
            double grandTotal   = Invoices.Sum(x => x.Total);
            string CustomerName = Invoices.Select(x => x.Customer.Name).First();

            InvoiceReviewModel result = new InvoiceReviewModel()
            {
                CustomerId   = Request.Id,
                CustomerName = CustomerName,
                StartDate    = Request.StartDate,
                EndDate      = Request.EndDate,
                GrandTotal   = grandTotal
            };

            result.Invoices = Invoices.OrderBy(x => x.InvoiceNo)
                              .Select(x => Factory.Create(x.Id, x.InvoiceNo, x.Date, x.ShippedOn, x.Total, x.Status.ToString())).ToList();

            return(result);
        }