// GET: SalesInvoices public ActionResult Index() { var salesInvoices = _salesInvoiceService.GetAllSalesInvoices(); var salesInvoiceViewModels = new List <SalesInvoiceViewModel>(); foreach (var salesInvoice in salesInvoices) { var salesInvoiceViewModel = new SalesInvoiceViewModel() { BranchId = salesInvoice.BranchId, CustomerId = salesInvoice.CustomerId, CustomerName = salesInvoice.Customer.FirstName + " " + salesInvoice.Customer.LastName, BranchName = salesInvoice.Branch.BranchName, DateSold = salesInvoice.DateSold, ReferenceNo = salesInvoice.ReferenceNo, SalesInvoiceId = salesInvoice.SalesInvoiceId, SalesType = salesInvoice.SalesType, UserId = salesInvoice.UserId, UserName = userManager.FindById(salesInvoice.UserId).FullName, Status = salesInvoice.Status }; salesInvoiceViewModels.Add(salesInvoiceViewModel); } ViewData["SalesList"] = new SelectList(_salesInvoiceService.GetAllSalesInvoices(), "SalesInvoiceId", "ReferenceNo"); return(View(salesInvoiceViewModels)); }
public void Can_fetch_all_Sales_Invoice_Lists() { List <SalesInvoice> expected = new List <SalesInvoice>(); { new SalesInvoice { SalesInvoiceId = 1, CustomerId = 1, BranchId = 1, SalesType = 0, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09") }; new SalesInvoice { SalesInvoiceId = 2, CustomerId = 2, BranchId = 2, SalesType = 1, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09") }; } List <SalesInvoice> actual = MockSalesInvoiceService.GetAllSalesInvoices(); Assert.AreEqual(actual.Count, expected.Count); }