public ViewResult Services()  //Вывод всех услуг
        {
            ServicesListViewModel obj = new ServicesListViewModel();

            obj.AllService = _AllService.Services;
            return(View(obj));
        }
        public ViewResult List(string category, int servicePage = 1)
        {
            var context = _serviceProvider.GetRequiredService <AppointmentJournalContext>();

            var services = context.Services.Where(p => category == null || p.Category.Name == category)
                           .OrderBy(p => p.CategoryId)
                           .Skip((servicePage - 1) * PageSize)
                           .Take(PageSize).AsEnumerable().Select(async x =>
            {
                x.Producer = await _userManager.FindByIdAsync(x.ProducerId);
                return(x);
            })
                           .Select(x => x.Result).ToList();

            var pagingInfo = new PagingInfo()
            {
                CurrentPage  = servicePage,
                ItemsPerPage = PageSize,
                TotalItems   = category == null?context.Services.Count() : context.Services.Where(e => e.Category.Name == category).Count()
            };

            var servicesListViewModel = new ServicesListViewModel()
            {
                CurrentCategory = category,
                PagingInfo      = pagingInfo,
                Services        = services
            };

            return(View(servicesListViewModel));
        }
        public async Task <IActionResult> GetServicesList(ServicesListViewModel model)
        {
            try
            {
                var query = _dataContext.Prices
                            .Include(x => x.Service)
                            .Include(x => x.Company)
                            .Where(x => model.ServiceIds.Contains(x.ServiceId))
                            .AsNoTracking();

                var prices = query.ToList();

                List <CompanyDistance> matrix = new List <CompanyDistance>();
                if (model.Lat.HasValue && model.Lng.HasValue)
                {
                    matrix = await _service.GetDistanceMatrix(new Location { Lng = model.Lng.Value, Lat = model.Lat.Value },
                                                              prices.Select(x => x.Company).Distinct().ToList());
                }

                return(Ok(new PricesViewModel(prices, matrix)));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);

                return(BadRequest(e.Message));
            }
        }
        public async Task <IActionResult> Index()
        {
            var viewModel = new ServicesListViewModel
            {
                Services = await this.servicesService.GetAllAsync <ServiceViewModel>(),
            };

            return(this.View(viewModel));
        }
        public ActionResult List(string category, int page = 1, string searchString = null)
        {
            if (!String.IsNullOrEmpty(searchString))
            {
                ServicesListViewModel model1 = new ServicesListViewModel
                {
                    Services = repository.Services
                               .Where(x => x.Name.Contains(searchString))
                               .OrderBy(service => service.ServiceId)
                               .Skip((page - 1) * pageSize)
                               .Take(pageSize),
                    PagingInfo = new PagingInfo
                    {
                        CurrentPage  = page,
                        ItemsPerPage = pageSize,
                        TotalItems   = repository.Services.Count()
                    },
                    CurrentCategory = null
                };
                return(View(model1));
            }
            else
            {
                ServicesListViewModel model2 = new ServicesListViewModel
                {
                    Services = repository.Services
                               .Where(p => category == null || p.ServiceType == category)
                               .OrderBy(service => service.ServiceId)
                               .Skip((page - 1) * pageSize)
                               .Take(pageSize),
                    PagingInfo = new PagingInfo
                    {
                        CurrentPage  = page,
                        ItemsPerPage = pageSize,
                        TotalItems   = category == null?
                                       repository.Services.Count() :
                                           repository.Services.Where(service => service.ServiceType == category).Count()
                    },
                    CurrentCategory = category
                };
                if (model2.Services != null && model2.Services?.Count() != 0)
                {
                    return(View(model2));
                }

                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
        }
        public ViewResult ServiceAbout()   //Вывод услуги
        {
            ServicesListViewModel obj = new ServicesListViewModel();

            obj.AllService = _AllService.Services;
            int     _Id  = int.Parse(HttpContext.Request.Query.Keys.Last());//Получение айди услуги
            Service serv = new Service();
            //IEnumerable<Service> Services;
            IEnumerator ie = obj.AllService.GetEnumerator();
            int         i  = 0;

            while ((ie.MoveNext()) & !(i == _Id))
            {
                serv = (Service)ie.Current;
                i++;
            }
            return(View(serv));
        }
        public IActionResult GetCompanyServicesInfo(ServicesListViewModel model)
        {
            try
            {
                var prices = _dataContext.Prices
                             .Include(x => x.Service)
                             .Include(x => x.Company)
                             .Where(x => model.ServiceIds.Contains(x.ServiceId))
                             .AsNoTracking()
                             .ToList();

                return(Ok(new PricesViewModel(prices, new List <CompanyDistance>())));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);

                return(BadRequest(e.Message));
            }
        }
Example #8
0
        public async Task <ServicesListViewModel> GetListAsync(ServicesSearchModel searchModel)
        {
            var pageInfo = new PageInfoViewModel();

            pageInfo.PageNumber = searchModel.Page;
            pageInfo.PageSize   = searchModel.ItemsPerPage;

            var getServices = context.Services.Where(x => x.IsApproved == searchModel.IsApproved);

            if (!String.IsNullOrWhiteSpace(searchModel.Search))
            {
                getServices = getServices.Where(x => x.Name.Contains(searchModel.Search));
            }
            if (searchModel.CategoryId != null)
            {
                getServices = getServices.Where(x => x.CategoryId == searchModel.CategoryId);
            }
            if (searchModel.SortAscending == true)
            {
                getServices = getServices.OrderBy(x => x.Name);
            }
            else
            {
                getServices = getServices.OrderByDescending(x => x.Name);
            }

            pageInfo.TotalItems = await getServices.CountAsync();

            var dataModel = await getServices
                            .Skip(pageInfo.SkipItems)
                            .Take(pageInfo.PageSize)
                            .Include(x => x.Category)
                            .ToListAsync();

            var viewModel = new ServicesListViewModel();

            viewModel.Services = _mapper.Map <List <ServiceViewModel> >(dataModel);
            viewModel.PageInfo = pageInfo;
            return(viewModel);
        }
Example #9
0
        public ServicesListPage()
        {
            InitializeComponent();

            BindingContext = new ServicesListViewModel(Navigation);
        }