Esempio n. 1
0
        public async Task <ActionResult> Find(SaleViewFilterModel saleViewFilterModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var coreModels = await _saleService.GetPagedListAsync(saleViewFilterModel.Page ?? 1, _pageSize)
                                     .ConfigureAwait(false);

                    var viewModels = _mapper.Map <IPagedList <SaleViewModel> >(coreModels);

                    return(PartialView("Partial/_SaleTable", viewModels));
                }


                var salesCoreModels = await _saleService.Filter(
                    _mapper.Map <SaleCoreFilterModel>(saleViewFilterModel), _pageSize);

                var salesViewModels = _mapper.Map <IPagedList <SaleViewModel> >(salesCoreModels);

                ViewBag.SaleFilterClientFirstNameValue = saleViewFilterModel.ClientName;
                ViewBag.SaleFilterClientLastNameValue  = saleViewFilterModel.ClientSurname;
                ViewBag.SaleFilterDateFromValue        = saleViewFilterModel.DateFrom;
                ViewBag.SaleFilterDateToValue          = saleViewFilterModel.DateTo;
                ViewBag.SaleFilterManagerLastNameValue = saleViewFilterModel.ManagerSurname;
                ViewBag.SaleFilterProductNameValue     = saleViewFilterModel.ProductName;
                ViewBag.SaleFilterSumFromValue         = saleViewFilterModel.SumFrom;
                ViewBag.SaleFilterSumToValue           = saleViewFilterModel.SumTo;

                return(PartialView("Partial/_SaleTable", salesViewModels));
            }
            catch (Exception exception)
            {
                ViewBag.Error = exception.Message;

                return(PartialView("Partial/_SaleTable"));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> Find(SaleFilterViewModel saleFilterViewModel)
        {
            try
            {
                #region Validation
                if (!ModelState.IsValid)
                {
                    var coreModels = await _saleService.GetUsingPagedListAsync(saleFilterViewModel.Page ?? 1, _pageSize)
                                     .ConfigureAwait(false);

                    var viewModels = _mapper.Map <IPagedList <SaleViewModel> >(coreModels);

                    return(PartialView("Partial/_SaleTable", viewModels));
                }
                #endregion

                # region Filter

                var salesCoreModels = _saleService.Filter(
                    _mapper.Map <SaleFilterCoreModel>(saleFilterViewModel), _pageSize);

                var salesViewModels = _mapper.Map <IPagedList <SaleViewModel> >(salesCoreModels);
                #endregion

                #region Filling ViewBag
                ViewBag.SaleFilterCustomerFirstNameValue = saleFilterViewModel.CustomerFirstName;
                ViewBag.SaleFilterCustomerLastNameValue  = saleFilterViewModel.CustomerLastName;
                ViewBag.SaleFilterDateFromValue          = saleFilterViewModel.DateFrom;
                ViewBag.SaleFilterDateToValue            = saleFilterViewModel.DateTo;
                ViewBag.SaleFilterManagerLastNameValue   = saleFilterViewModel.ManagerLastName;
                ViewBag.SaleFilterProductNameValue       = saleFilterViewModel.ProductName;
                ViewBag.SaleFilterSumFromValue           = saleFilterViewModel.SumFrom;
                ViewBag.SaleFilterSumToValue             = saleFilterViewModel.SumTo;
                #endregion

                return(PartialView("Partial/_SaleTable", salesViewModels));
            }