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));
        }
Esempio n. 2
0
        public async Task <Pager <CustomerTagViewModel> > GetCustomerTags([FromQuery] PagerFilterViewModel model)
        {
            var result = await _businessManager.GetCustomerTags(_mapper.Map <PagerFilterDto>(model));

            var pager = new Pager <CustomerTagViewModel>(_mapper.Map <List <CustomerTagViewModel> >(result.Items), result.TotalItems, result.CurrentPage, result.PageSize);

            return(pager);
        }
        public async Task <IActionResult> Create(InvoiceConstructorSearchViewModel model)
        {
            try {
                if (ModelState.IsValid)
                {
                    var item = await _businessManager.CreateInvoiceConstructorSearchCriterias(_mapper.Map <InvoiceConstructorSearchDto>(model));

                    if (item == null)
                    {
                        return(NotFound());
                    }
                    //model = _mapper.Map<CustomerViewModel>(item);
                    return(RedirectToAction(nameof(Edit), new { id = item.Id }));
                }
            } catch (Exception er) {
                _logger.LogError(er, er.Message);
            }

            // ReportSearchCriteriaViewModel model = new ReportSearchCriteriaViewModel();
            var customerTags = await _businessManager.GetCustomerTags();

            ViewBag.CustomerTags = customerTags.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            var customerTypes = await _customerBusinessManager.GetCustomerTypes();

            ViewBag.CustomerTypes = customerTypes.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            var rechecks = model.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("Create", model));
        }
        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));
            }
        }
Esempio n. 5
0
        // 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));
        }
Esempio n. 6
0
        public async Task <Pager <InvoiceListViewModel> > GetInvoices([FromQuery] InvoiceFilterViewModel model)
        {
            var result = await _businessManager.GetInvoicePage(_mapper.Map <InvoiceFilterDto>(model));

            var list = _mapper.Map <List <InvoiceListViewModel> >(result.Items);

            foreach (var invoice in list)
            {
                var tags = await _businessManager.GetCustomerTags(invoice.CustomerId);

                if (tags != null)
                {
                    invoice.CustomerTags = tags.Select(x => x.Name).ToArray();
                }
            }

            return(new Pager <InvoiceListViewModel>(list, result.TotalItems, result.CurrentPage, result.PageSize, result.Params));
        }