public IEnumerable <DestinationViewModel> Get()
        {
            List <Business.Modules.Destination.Model.Destination> destinations = _destinationSvc.GetAll();
            List <DestinationViewModel> destinationModel = destinations.ToViewModel <List <Business.Modules.Destination.Model.Destination>, List <DestinationViewModel> >();

            return(destinationModel);
        }
Beispiel #2
0
        public DestinationRoutes(IDestinationService desService)
            : base("v1")
        {
            this.RequiresAuthentication();

            Get("/destination/{name}", _ =>
            {
                this.RequiresClaims(c => c.Type == HttpMethod.Get.Verb());
                var name = (string)_.name;
                ValidateRequest(name, Context.User().Destinations);
                Destination destination = desService.GetByName(name);
                return(AddDestinationCategoriesToProperties(destination).ToViewModel <Destination, ADModel.Destination>());
            });

            Get("/destinations", _ =>
            {
                this.RequiresClaims(c => c.Type == HttpMethod.Get.Verb());
                var destinations = desService.GetAll();

                // retrieve permitted destinations
                var permittedDestinations = FilterDestinations(destinations, Context.User().Destinations);

                return(AddListDestinationsCategoriesToProperties(permittedDestinations).ToViewModel <List <Destination>, List <ADModel.Destination> >());
            });
        }
Beispiel #3
0
        public IEnumerable <CategoryViewModel> Get()
        {
            List <CategoryViewModel> categoriesVM = new List <CategoryViewModel>();
            List <Business.Modules.Destination.Model.Destination> destinations = _destinationSvc.GetAll();

            var categories = destinations.SelectMany(d => d.Categories);

            foreach (var category in categories.GroupBy(e => e.Name))
            {
                CategoryViewModel categoryVM = new CategoryViewModel
                {
                    Id           = Guid.NewGuid().ToString(),
                    Name         = category.Key,
                    Destinations = destinations.Where(e => e.Categories.Any(f => f.Name == category.Key)).ToList()
                                   .ToViewModel <List <Business.Modules.Destination.Model.Destination>, List <DestinationViewModel> >()
                };

                foreach (var destination in categoryVM.Destinations)
                {
                    destination.Categories = new List <Category> {
                        destination.Categories.First(e => e.Name == category.Key)
                    };
                }

                categoriesVM.Add(categoryVM);
            }

            return(categoriesVM);
        }
Beispiel #4
0
        public IEnumerable <UserPermission> Get(string type)
        {
            var permissionLists = _service.GetAll(type == "system" ? UserType.Api : UserType.Portal).OrderBy(e => e.UserName).ToList()
                                  .ToViewModel <List <BLModel.UserPermission>, List <UserPermission> >();

            List <Business.Modules.Destination.Model.Destination> destinations = _destinationSvc.GetAll();
            var modules = _service.GetAllPortalModules();
            var queues  = _queueSvc.GetQueues().OrderBy(o => o.FriendlyName).ToList();
            var brands  = _brandSvc.GetAllBrands();

            if (type == "system")
            {
                foreach (var permission in permissionLists)
                {
                    if (!string.IsNullOrEmpty(permission.Api.TechnicalContactId))
                    {
                        permission.Api.TechnicalContactUser = _service.GetById(permission.Api.TechnicalContactId).ToViewModel <BLModel.UserPermission, UserPermission>();
                    }
                    if (!string.IsNullOrEmpty(permission.Api.FunctionalContactId))
                    {
                        permission.Api.FunctionalContactUser = _service.GetById(permission.Api.FunctionalContactId).ToViewModel <BLModel.UserPermission, UserPermission>();
                    }

                    if (permission.Api.DestinationPermitAll)
                    {
                        permission.Api.Destinations = null;
                        permission.Api.Destinations = destinations.Select(s => s.Name).ToList();
                    }

                    if (permission.Api.BrandPermitAll)
                    {
                        permission.Api.Brands = null;
                        permission.Api.Brands = brands;
                    }
                }
            }
            else
            {
                foreach (var module in modules)
                {
                    foreach (var permission in permissionLists)
                    {
                        if (!permission.Portal.ModulePermissions.ContainsKey(module.ModuleName))
                        {
                            permission.Portal.ModulePermissions.Add(module.ModuleName, new Permission(permission.Portal.IsAdmin));
                        }
                    }
                }
                foreach (var permission in permissionLists)
                {
                    foreach (var queue in queues)
                    {
                        if (!permission.Portal.DeliveryQueuePermissions.ContainsKey(queue.Name))
                        {
                            permission.Portal.DeliveryQueuePermissions.Add(queue.Name, new Permission(permission.Portal.IsAdmin));
                        }
                    }

                    if (permission.Api.DestinationPermitAll)
                    {
                        permission.Api.Destinations = null;
                        permission.Api.Destinations = destinations.Select(s => s.Name).ToList();
                    }

                    if (permission.Api.BrandPermitAll)
                    {
                        permission.Api.Brands = null;
                        permission.Api.Brands = brands;
                    }
                }
            }

            return(permissionLists);
        }
 protected override void InitCollection()
 {
     Material    = new ListCollectionView((new[] { NullMaterial }).Concat(_MaterialService.GetAll()).ToList());
     Destination = new ListCollectionView((new[] { NullDestination }).Concat(_DestinationService.GetAll()).ToList());
 }