public async Task UpdateAsync(int id, CreateEditInputModel input) { var product = this.productRepository.All().FirstOrDefault(x => x.Id == id); product.Name = input.Name; product.ProductTypeId = input.ProductTypeId; product.Price = input.Price; await this.productRepository.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, CreateEditInputModel input) { if (!this.ModelState.IsValid) { input.ProductTypes = this.productTypesService.GetAll <ProductTypeDropDownViewModel>(); return(this.View(input)); } await this.productsService.UpdateAsync(id, input); return(this.RedirectToAction(nameof(this.ById), new { id })); }