public async Task ChangeProductSupplier(ChangeProductSupplierModel changeProductSupplierModel) { var product = this.context.Products.Where(x => x.Id == changeProductSupplierModel.ProductId).FirstOrDefault(); var suppliers = await GetSupplierNames(); product.Supplier = suppliers[changeProductSupplierModel.NewSupplierIndex].Name; this.context.Products.Update(product); await this.context.SaveChangesAsync(); }
public async Task <IActionResult> ChangeSupplierToProduct(ChangeProductSupplierModel changeProductSupplierModel) { if (!ModelState.IsValid) { return(BadRequest()); } await this.productService.ChangeProductSupplier(changeProductSupplierModel); return(RedirectToAction("ChangeProductSupplier")); }