Exemplo n.º 1
0
        public async Task <ActionResult> Create()
        {
            var model = new ProductViewModel()
            {
                Categories = await _categoryRepostitory.GetAllAsync(),
            };


            return(View(model: model, viewName: "Create"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Index()
        {
            var categoryies = await _repository.GetAllAsync();

            if (Request.AcceptTypes.Contains("application/json"))
            {
                return(Json(categoryies, JsonRequestBehavior.AllowGet));
            }

            if (User.IsInRole("author"))
            {
                return(new HttpUnauthorizedResult());
            }

            return(View(model: categoryies, viewName: "Index"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            var users = await _userRepository.GetAllUsersAsync();

            var model = new DashboardViewModel()
            {
                UserLogin  = User.Identity.Name,
                Users      = users.Select(u => u.Roles.Where(r => r.RoleId == "54ec7407-2468-4579-82d9-99e701f5c761")).Count(),
                Price      = 0,
                Domain     = 0,
                Host       = 0,
                Categories = await _categoryRepostitory.GetAllAsync()
            };

            if (User.IsInRole("admin"))
            {
                model.Role = "Admin";
            }
            else if (User.IsInRole("editor"))
            {
                model.Role = "Editor";
            }
            else if (User.IsInRole("author"))
            {
                model.Role = "Author";
            }


            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Index()
        {
            var products = await _productRepository.GetAllAsync();

            var categories = await _categoryRepostitory.GetAllAsync();

            var cart = new ShoppingCart(HttpContext);

            var carts = await cart.GetCartItemsAsync();

            if (carts == null)
            {
                await cart.AddAsync(11);
            }
            else
            {
                await cart.RemoveAsync(11);
            }

            var model = new ProductsViewModel()
            {
                Products   = products,
                CartItems  = carts,
                Categories = categories,
            };

            return(View(viewName: "Index", model: model));
        }