예제 #1
0
        public IActionResult Order(ProductOrderInputModel productOrder)
        {
            var product = this.productsService.GetByName(productOrder.Product);

            this.orderService.AddProductToCurrentActiveOrder(product.Id, User.Id);


            return(Redirect("/"));
        }
        public string GetId(ProductOrderInputModel model)
        {
            var id = this.Data.Products
                     .Where(p => p.Name == model.Product)
                     .Select(u => u.Id)
                     .FirstOrDefault();

            return(id);
        }
예제 #3
0
        public async Task <IActionResult> Order(ProductOrderInputModel productOrderInputModel)
        {
            OrderServiceModel orderServiceModel = productOrderInputModel.To <OrderServiceModel>();

            orderServiceModel.IssuerId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.orderService.CreateOrder(orderServiceModel);

            return(this.Redirect("/"));
        }
예제 #4
0
        public async Task <IActionResult> Order(ProductOrderInputModel input)
        {
            var orderCreateViewModel = new OrderCreateViewModel
            {
                ProductId = input.ProductId,
                Quantity  = input.Quantity,
                UserId    = this.userManager.GetUserId(this.User),
            };

            await this.orderService.CreateOrder(orderCreateViewModel);

            return(this.Redirect("/Orders/Cart"));
        }
예제 #5
0
        public async Task <IActionResult> Order(ProductOrderInputModel inputModel)
        {
            OrderServiceModel orderServiceModel = inputModel.To <OrderServiceModel>();

            //orderServiceModel.IssuerId = this.User.Identity.Name;
            //note: това търси този, който го е създал, а не този, който купува!!!! ?????

            orderServiceModel.IssuerId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            await this.orderService.CreateOrder(orderServiceModel);


            return(this.Redirect("/Home/Index"));
        }
예제 #6
0
        public IActionResult Order(ProductOrderInputModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.Redirect("/"));
            }

            Product orderedProduct = this.productService.GetProductByName(model.Product);

            this.orderService.AddProduct(this.User.Id, orderedProduct.Id);

            return(this.Redirect("/"));
        }
예제 #7
0
        public async Task <IActionResult> Order(ProductOrderInputModel productOrderInputModel)
        {
            var orderServiceModel = new OrderServiceModel
            {
                ProductId = productOrderInputModel.ProductId,
                Quantity  = productOrderInputModel.Quantity,
            };

            orderServiceModel.IssuerId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.orderService.CreateOrder(orderServiceModel);

            return(this.Redirect("/"));
        }
예제 #8
0
        public async Task <IActionResult> Order(ProductOrderInputModel productOrderInputModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.Redirect($"/Product/Details/{productOrderInputModel.ProductId}"));
            }

            var orderServiceModel = productOrderInputModel.To <OrderServiceModel>();

            orderServiceModel.IssuerId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.orderService.CreateOrder(orderServiceModel);

            return(this.Redirect("/"));
        }
예제 #9
0
        public HttpResponse Order(ProductOrderInputModel model)
        {
            if (!User.IsAuthenticated)
            {
                return(this.Redirect("/Users/Login"));
            }

            var productId = this.productService.GetId(model);

            if (productId == null)
            {
                return(this.Error("Product not found."));
            }

            this.ordersService.Create(this.User.Id, productId);

            return(this.Redirect("/"));
        }
        public HttpResponse Order(ProductOrderInputModel input)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            var userId    = this.User;
            var productId = this.productsService.GetId(input.Product);

            if (productId == null)
            {
                return(this.Error("Product not found."));
            }

            this.ordersService.Create(userId, productId);

            return(this.Redirect("/"));
        }