public async Task <IActionResult> View(long id) { var constructor = await _businessManager.GetConstructorInvoice(id); var summaryRange = await _companyBusinessManager.GetSummaryRange(constructor.SummaryRangeId); ViewBag.SummaryRange = $"{summaryRange.From} - {summaryRange.To}"; var searchCriteria = await _businessManager.GetInvoiceConstructorSearchCriteria(constructor.SearchCriteriaId); ViewBag.SearchCriteria = _mapper.Map <InvoiceConstructorSearchViewModel>(searchCriteria); if (searchCriteria.Group == CustomerGroupType.OnlyNew) { ViewBag.CreatedDate = $"{constructor.Date.FirstDayOfMonth().ToString("MM/dd/yyyy")} - {constructor.Date.LastDayOfMonth().ToString("MM/dd/yyyy")}"; } else if (searchCriteria.Group == CustomerGroupType.ExcludeNew) { ViewBag.CreatedDate = $"None - {constructor.Date.AddMonths(-1).LastDayOfMonth().ToString("MM/dd/yyyy")}"; } else if (searchCriteria.Group == CustomerGroupType.All) { ViewBag.CreatedDate = $"None - {constructor.Date.LastDayOfMonth().ToString("MM/dd/yyyy")}"; } var tags = await _businessManager.GetCustomerTags(); ViewBag.Tags = string.Join(',', tags.Where(x => searchCriteria.TagsIds.Contains(x.Id)).Select(x => x.Name)); var types = await _businessManager.GetCustomerTypes(); ViewBag.Types = string.Join(',', types.Where(x => searchCriteria.TypeIds.Contains(x.Id)).Select(x => x.Name)); var constructors = await _businessManager.GetConstructorInvoices(constructor.CompanyId, constructor.Date); constructors = constructors.Where(x => x.SearchCriteriaId == constructor.SearchCriteriaId).ToList(); var invoices = await _businessManager.GetInvoiceDraft(constructors.Select(x => x.Id).ToArray()); ViewBag.Invoices = invoices.Count(); var customers = await _businessManager.GetCustomers(constructor); ViewBag.Customers = customers.Count(); var model = _mapper.Map <InvoiceConstructorViewModel>(constructor); if (IsAjaxRequest) { return(PartialView(model)); } else { return(View(model)); } }
public async Task <ActionResult> Edit(long id) { var item = await _businessManager.GetInvoiceConstructorSearchCriteria(id); if (item == null) { return(NotFound()); } var customerTags = await _businessManager.GetCustomerTags(); ViewBag.CustomerTags = customerTags.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(); var customerTypes = await _businessManager.GetCustomerTypes(); ViewBag.CustomerTypes = customerTypes.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(); var rechecks = item.Recheck; if (rechecks == null || rechecks.Count() == 0) { rechecks.Add(0); } ViewBag.CustomerRechecks = rechecks.Select(x => new SelectListItem() { Text = x.ToString(), Value = x.ToString() }).ToList(); return(View(_mapper.Map <InvoiceConstructorSearchViewModel>(item))); }