public RCTInvoiceViewModel GetInvoiceModel(List<InvoiceDto> listInvoice)
        {
            UserDto specialist = listInvoice.First().User;

            RCTInvoiceViewModel model = new RCTInvoiceViewModel()
            {
                Teleconsult = new BasicUserInfoViewModel()
                {
                    Address = "Suite 102, 19-21 Berry Street",
                    Name = "TeleConsult",
                    Postcode = "2060",
                    State = "NSW",
                    Suburb = " ",
                    ABN = "20 767 279",
                },

                User = new BasicUserInfoViewModel(),

                CreatedDate = DateTime.Now.ToString(Constants.GlobalDateFormat, new CultureInfo("en-US")),
                Invoice = new List<InvoiceDetailViewModel>(),
            };
            model.User = Mapper.Map<UserDto, BasicUserInfoViewModel>(specialist);

            decimal totalGST = 0;
            decimal totalValue = 0;
            decimal totalPrice = 0;

            foreach (var invoice in listInvoice)
            {
                invoice.Description = string.Format("{0} ({1}Duration:{2} - Date:{3})", invoice.Description,
                    string.Format("{0}", invoice.ConsultationType == ConsultationType.MinimumCharge ? null : invoice.ConsultationType + " - "),
                    string.Format("{0}", invoice.Duration != 0 ? TimeSpan.FromSeconds(invoice.Duration).ToString() : "N/A")
                    , invoice.CreatedDate.ToString(Constants.GlobalDateFormat, new CultureInfo("en-US")));

                totalGST += invoice.GST;
                totalValue += invoice.Amount;
                totalPrice += (invoice.Amount + invoice.GST);
            }

            model.Invoice = Mapper.Map<List<InvoiceDto>, List<InvoiceDetailViewModel>>(listInvoice);

            model.TotalValue = totalValue.ToString("C", new CultureInfo("en-US"));
            model.TotalGST = totalGST.ToString("C", new CultureInfo("en-US"));
            model.TotalPrice = totalPrice.ToString("C", new CultureInfo("en-US"));

            model.DepositedAmount = model.TotalPrice;

            return model;
        }
Esempio n. 2
0
 public RCTInvoiceViewModel(RCTInvoiceViewModel model)
 {
     this.TotalGST = model.TotalGST;
     this.TotalPrice = model.TotalPrice;
     this.TotalValue = model.TotalValue;
     this.CreatedDate = model.CreatedDate;
     this.Invoice = model.Invoice;
     this.Teleconsult = model.Teleconsult;
     this.User = model.User;
 }