public async Task <IActionResult> CreateReportSearchCriteriaView([FromQuery] InvoiceConstructorSearchViewModel model) { var customerTags = await _businessManager.GetCustomerTags(); var customerTypes = await _businessManager.GetCustomerTypes(); var rechecks = model.Recheck ?? new List <int>(); if (rechecks == null || rechecks.Count() == 0) { rechecks.Add(0); } var viewDataDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { { "customerTags", customerTags.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList() }, { "CustomerTypes", customerTypes.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList() }, { "CustomerRechecks", rechecks.Select(x => new SelectListItem() { Text = x.ToString(), Value = x.ToString() }).ToList() } }; string html = await _viewRenderService.RenderToStringAsync("_CreateReportSearchCriteriaPartial", model, viewDataDictionary); return(Ok(html)); }
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))); }
// GET: Invoice/Bulk public async Task <ActionResult> Bulk() { var companies = await _companyBusinessManager.GetCompanies(); ViewBag.Companies = companies.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(); var selectedCompany = companies.FirstOrDefault(); var model = new CustomerFilterViewModel() { CompanyId = selectedCompany?.Id ?? 0, DateFrom = DateTime.Now.FirstDayOfMonth(), DateTo = DateTime.Now.LastDayOfMonth() }; var summary = await _companyBusinessManager.GetSummaryRanges(selectedCompany?.Id ?? 0); ViewBag.SummaryRange = summary.Select(x => new SelectListItem() { Text = $"{x.From} - {x.To}", Value = x.Id.ToString() }); var customerTags = await _businessManager.GetCustomerTags(); ViewBag.Tags = customerTags.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }); var customerTypes = await _businessManager.GetCustomerTypes(); ViewBag.CustomerTypes = customerTypes.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }); //var customers = await _businessManager.GetBulkCustomers(selectedCompany?.Id ?? 0, model.DateFrom, model.DateTo); //ViewBag.Customers = _mapper.Map<List<CustomerListViewModel>>(customers); return(View(model)); }
public async Task <IActionResult> FilterView([FromQuery] InvoiceFilterViewModel model) { var companies = await _companyBusinessManager.GetCompanies(); var customerTypes = await _businessManager.GetCustomerTypes(); var viewDataDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { { "Companies", companies.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList() }, { "CustomerTypes", customerTypes.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList() } }; string html = await _viewRenderService.RenderToStringAsync("_FilterInvoicePartial", model, viewDataDictionary); return(Ok(html)); }