// GET: AddOns
        public async Task <ActionResult> Index()
        {
            var currentUserId = await _customerIdService.GetCustomerId();

            var addOns = await _addOnRepository.GetAll().Where(x => x.CustomerId == currentUserId).OrderBy(y => y.ProductType.Name).ToListAsync();

            return(View(addOns));
        }
        private async Task <IEnumerable <ProdctTypeViewModel> > GetProductTypeViewModels()
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            return(_productTypeRepository.GetAll().Where(c => c.CustomerId == currentCustomerId)
                   .Select(x => new ProdctTypeViewModel {
                Description = x.Description, Id = x.Id, Name = x.Name
            }));
        }
        public async Task <ActionResult> PricePlans(int productTypeId)
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            var pricePlansViewModels = await _pricePlanService.GetPricePlanDropDownViewModelsByIds(currentCustomerId,
                                                                                                   productTypeId);

            return(Json(pricePlansViewModels, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> GetPricePlans()
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            var pricePlans          = _pricePlanRepository.GetAll().Where(x => x.CustomerId == currentCustomerId);
            var pricePlanViewModels = new List <PricePlanViewModel>();

            // DO NOT resharper this, it doesn't work
            foreach (var plan in pricePlans)
            {
                var viewModel = _pricePlanViewModelFactory.Create(plan);
                pricePlanViewModels.Add(viewModel);
            }

            return(Json(pricePlanViewModels, JsonRequestBehavior.AllowGet));
        }
        private async Task <Customer> GetCurrentCustomer()
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            var currentCustomer = await _customerRepository.GetByIdAsync(currentCustomerId);

            return(currentCustomer);
        }
        public async Task <IEnumerable <ProductCatagoryViewModel> > CreateViewModel()
        {
            var customerId = await _customerIdService.GetCustomerId();

            var viewModel = await _categoryRepository.GetAll().Where(i => i.CustomerId == customerId).OrderBy(y => y.Name).Select(x => new ProductCatagoryViewModel {
                CategoryId = x.Id, SubCategories = x.SubCategories, CategoryDescription = x.Description, CategoryName = x.Name
            }).ToListAsync();

            return(viewModel);
        }
Example #7
0
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, CustomerIdRequirement requirement)
        {
            if (!_authContext.IsUserContext())
            {
                return(Task.CompletedTask);
            }

            var claimsCustomerId = _authContext.GetCustomerIdFromClaims();

            var asd = context.Resource as AuthorizationFilterContext;

            var customerId = _customerIdService.GetCustomerId();

            if (!customerId.HasValue || customerId.Value == claimsCustomerId)
            {
                context.Succeed(requirement);
            }

            return(Task.CompletedTask);
        }
 public async Task <IEnumerable <IEmployee> > SearchEmployee(ISearchQueryEmployee query)
 {
     return(await Request <IEnumerable <Employee> >($"{_customerIdService.GetCustomerId()}/employees?{WebUtility.GetQueryString(query)}"));
 }
 public async Task <Integration> GetIntegration(int id)
 {
     return(await Request <Integration>($"{_customerIdService.GetCustomerId()}/integrations/{id}"));
 }
Example #10
0
        // GET: ProductTypes
        public async Task <ActionResult> Index()
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            return(View(await _productTypeRepository.GetAll().Where(x => x.CustomerId == currentCustomerId).ToListAsync()));
        }
        public async Task <ActionResult> Create(CreateCategoryViewModel category)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }
            var item = new Category {
                Name = category.Name, Description = category.Description, CustomerId = await _customerIdService.GetCustomerId()
            };
            await _categoryRepository.Add(item);

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create(CreateSubCategoryViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var subCategory = new SubCategory {
                    CategoryId = viewModel.CategoryId, Name = viewModel.Name, Description = viewModel.Description, CustomerId = await _customerIdService.GetCustomerId()
                };
                await _subCategoryRepository.Add(subCategory);

                return(RedirectToAction("Details", "Category", new { Id = viewModel.CategoryId }));
            }

            return(View(viewModel));
        }