Exemple #1
0
        public virtual ActionResult GetAll([DataSourceRequest] DataSourceRequest request,
                                           DateTime?dateFrom,
                                           DateTime?dateTo,
                                           string buyerName,
                                           string orderNumber)
        {
            LogI("GetAll");

            var filter = new CustomerFilterViewModel()
            {
                DateFrom    = dateFrom,
                DateTo      = dateTo,
                BuyerName   = buyerName,
                OrderNumber = orderNumber
            };

            request.Sorts = new List <SortDescriptor>()
            {
                new SortDescriptor("CreateDate", ListSortDirection.Descending)
            };
            var items      = CustomerViewModel.GetAll(Db, filter);
            var dataSource = items.ToDataSourceResult(request);

            return(new JsonResult {
                Data = dataSource, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemple #2
0
        public ActionResult Index(string firstName, string lastName, string city, string street, GridSortOptions gridSortOptions, [DefaultValue(1)] int page)
        {
            // Pobranie listy użytkowników
            var customersList = _customerRepo.GetAllCustomers();

            // Ustawienie domyślnej kolumny sortowania
            if (string.IsNullOrWhiteSpace(gridSortOptions.Column))
            {
                gridSortOptions.Column = "Id";
            }

            // Filtrowanie po imieniu
            if (!string.IsNullOrWhiteSpace(firstName))
            {
                customersList = customersList.Where(a => a.FirstName.Contains(firstName));
            }

            // Filtrowanie po nazwisku
            if (!string.IsNullOrWhiteSpace(lastName))
            {
                customersList = customersList.Where(a => a.LastName.Contains(lastName));
            }

            // Filtrowanie po mieście
            if (!string.IsNullOrWhiteSpace(city))
            {
                customersList = customersList.Where(a => a.City.Contains(city));
            }

            // Filtrowanie po ulicy
            if (!string.IsNullOrWhiteSpace(street))
            {
                customersList = customersList.Where(a => a.Street.Contains(street));
            }

            var customerFilterViewModel = new CustomerFilterViewModel();

            // Sortowanie listy użytkowników oraz stronicowanie
            var customerPagedList = customersList.OrderBy(gridSortOptions.Column, gridSortOptions.Direction)
                                    .AsPagination(page, 5);

            CustomerListContainerViewModel customerListContainer = new CustomerListContainerViewModel
            {
                CustomerPagedList       = customerPagedList,
                CustomerFilterViewModel = customerFilterViewModel,
                GridSortOptions         = gridSortOptions
            };

            return(View(customerListContainer));
        }
Exemple #3
0
        public virtual ActionResult ExportToExcel()
        {
            LogI("ExportToExcel");

            var filters = new CustomerFilterViewModel();

            string filename = "CustomerReport_" + Time.GetAppNowTime().ToString("ddMMyyyyHHmmss") + ".xls";
            var    output   = CustomerViewModel.ExportToExcel(LogService,
                                                              Time,
                                                              Db,
                                                              filters);

            return(File(output.ToArray(),           //The binary data of the XLS file
                        "application/vnd.ms-excel", //MIME type of Excel files
                        filename));                 //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }
Exemple #4
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));
        }
Exemple #5
0
        public ActionResult Index(string FirstName, string LastName, string City, string Street, GridSortOptions sort, [DefaultValue(1)] int page)
        {
            IQueryable <CustomerViewModel> customerList = _customerRepo.GetAllCustomer();

            if (string.IsNullOrWhiteSpace(sort.Column))
            {
                sort.Column = "CustomerId";
            }

            if (!string.IsNullOrWhiteSpace(FirstName))
            {
                customerList = customerList.Where(c => c.FirstName.Contains(FirstName));
            }

            if (!string.IsNullOrWhiteSpace(LastName))
            {
                customerList = customerList.Where(c => c.LastName.Contains(LastName));
            }

            if (!string.IsNullOrWhiteSpace(City))
            {
                customerList = customerList.Where(c => c.City.Contains(City));
            }

            if (!string.IsNullOrWhiteSpace(Street))
            {
                customerList = customerList.Where(c => c.Street.Contains(Street));
            }

            //potrzebna przestrzen nazw using MvcContrib.Sorting;
            var customerPagedList = customerList.OrderBy(sort.Column, sort.Direction).AsPagination(page, 5);

            CustomerFilterViewModel customerFilterViewModel = new CustomerFilterViewModel();

            CustomerListContainerViewModel customerListContainerViewModel = new CustomerListContainerViewModel
            {
                CustomerPageList        = customerPagedList,
                CustomerFilterViewModel = customerFilterViewModel,
                GridSortOptions         = sort
            };

            return(View(customerListContainerViewModel));
        }
        public async Task <ActionResult> Find(CustomerFilterViewModel customerFilterViewModel)
        {
            try
            {
                #region Validation
                if (!ModelState.IsValid)
                {
                    var coreModels = await _customerService
                                     .GetUsingPagedListAsync(customerFilterViewModel.Page ?? 1, _pageSize)
                                     .ConfigureAwait(false);

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

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

                #region Filter
                var customersCoreModels = _customerService.Filter(
                    _mapper.Map <CustomerFilterCoreModel>(customerFilterViewModel), _pageSize);

                var customersViewModels = _mapper.Map <IPagedList <CustomerViewModel> >(customersCoreModels);
                #endregion

                #region Filling ViewBag
                ViewBag.CustomerFilterFirstNameValue = customerFilterViewModel.FirstName;
                ViewBag.CustomerFilterLastNameValue  = customerFilterViewModel.LastName;
                #endregion

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

                return(PartialView("Partial/_CustomerTable"));
            }
        }