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 <ActionResult> Edit(long id, InvoiceConstructorSearchViewModel model)
        {
            try {
                if (ModelState.IsValid)
                {
                    var item = await _businessManager.UpdateInvoiceConstructorSearchCriterias(id, _mapper.Map <InvoiceConstructorSearchDto>(model));

                    if (item == null)
                    {
                        return(NotFound());
                    }
                    return(RedirectToAction(nameof(Edit), new { id = item.Id }));
                }
            } catch (Exception er) {
                _logger.LogError(er, er.Message);
            }

            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();

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

                if (item == null)
                {
                    return(NotFound());
                }
                return(Ok(_mapper.Map <InvoiceConstructorSearchViewModel>(item)));
            }
            return(BadRequest(model));
        }
        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));
        }