// GET: Service
        public ActionResult Index()
        {
            var model = new ServiceIndexViewModel();

            model.services = serviceRepo.ResultTable.ToList();
            return(View(model));
        }
Ejemplo n.º 2
0
        public ServiceIndexViewModel GetIndexPageInformation(string typeService, string customer, IDataProtector protector, Guid idAccount)
        {
            var idTypeService = Guid.Empty;
            var idCustomer    = Guid.Empty;

            if (!string.IsNullOrEmpty(typeService))
            {
                idTypeService = Guid.Parse(protector.Unprotect(typeService));
            }

            if (!string.IsNullOrEmpty(customer))
            {
                idCustomer = Guid.Parse(protector.Unprotect(customer));
            }

            var model = new ServiceIndexViewModel
            {
                TypeServicesList = _typeServiceDao.GetAll()
                                   .Select(
                    t =>
                    new TypeServiceListViewModel()
                {
                    Id   = protector.Protect(t.Id.ToString()),
                    Name = t.Name
                })
                                   .ToList(),
                Customers =
                    _customerDao.GetCustomerByTypeService(idTypeService, idAccount)
                    .Select(
                        c =>
                        new ServiceCustomerViewModel()
                {
                    Id            = protector.Protect(c.Id.ToString()),
                    Name          = c.Name,
                    IdTypeService = typeService
                })
                    .ToList(),
                Services =
                    _serviceDao.GetServicesByCustomerId(idAccount, idCustomer)
                    .Select(
                        s =>
                        new ServiceItemViewModel()
                {
                    Id             = protector.Protect(s.Id.ToString()),
                    Name           = s.Name,
                    IdCustomer     = customer,
                    IdTypeBusiness = typeService,
                    Icon           = s.Icon,
                    IconColor      = s.IconColor
                })
                    .ToList()
            };


            return(model);
        }
Ejemplo n.º 3
0
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            var repo     = new ServiceRepository();
            var services = await repo.GetAllAsync();

            var model = new ServiceIndexViewModel
            {
                Services = services,
            };

            repo.Dispose();

            return(View(model));
        }
Ejemplo n.º 4
0
        public IActionResult Index(int page = 1)
        {
            var services = _serviceManager.Get(page);

            var config     = new MapperConfiguration(cfg => cfg.CreateMap <ServiceModel, ServiceViewModel>());
            var mapper     = new Mapper(config);
            var servicesVM = mapper.Map <List <ServiceViewModel> >(services.Service);

            var indexVM = new ServiceIndexViewModel
            {
                Service       = servicesVM,
                PageViewModel = services.PageViewModel
            };

            return(View(indexVM));
        }