public async Task <IActionResult> Edit(ProductFormAdminViewModel model)
        {
            await this.products.Edit(model.Id, model.Name, model.Price, model.Description, model.Type);

            return(RedirectToAction(
                       nameof(Web.Controllers.ProductsController.Details).Replace("Controller", string.Empty),
                       nameof(ProductsController).Replace("Controller", string.Empty),
                       new { area = string.Empty, id = model.Id }));
        }
        public async Task <IActionResult> Create(ProductFormAdminViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await this.products.CreateAsync(model.Name, model.Price, model.Description, model.Type);

            return(ControllerExtensions.RedirectToHomeIndex(this));
        }
        public IActionResult Create()
        {
            var types = this.GetTypesOfProduct();

            var model = new ProductFormAdminViewModel
            {
                Types = types
            };

            return(View(model));
        }
        public async Task <IActionResult> Edit(int id)
        {
            var product = await this.products.ById(id);

            var model = new ProductFormAdminViewModel
            {
                Name        = product.Name,
                Price       = product.Price,
                Description = product.Description,
                Type        = product.Type,
                Types       = this.GetTypesOfProduct()
            };

            return(View(model));
        }