示例#1
0
        public async Task ProductEditAsync(AdminEditProductBindingModel product, int id)
        {
            var model = DbContext.Products.FirstOrDefault(i => i.Id == id);

            Mapper.Map(product, model);
            DbContext.Products.Update(model);
            await DbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> ProductEdit(int id, AdminEditProductBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                RedirectToAction("EditProduct");
            }
            await _productsService.ProductEditAsync(model, id);

            return(RedirectToAction("ProductsAdmin"));
        }