public async Task <bool> Update(VendorEditViewModel vendor) { try { if (vendor.ProductIds.Count >= 1) { foreach (int id in vendor.ProductIds) { var productVendor = new ProductVendorViewModel { VendorId = vendor.Id, ProductId = id }; var mappedToDomain = this.Mapper.Map <ProductVendor>(productVendor); this.DbContext.ProductVendor.Add(mappedToDomain); } } var mapped = this.Mapper.Map <Vendor>(vendor); DbContext.Vendors.Update(mapped); DbContext.Entry(vendor).State = EntityState.Modified; await DbContext.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException ex) { throw ex; } }
public ProductVendorView(ProductVendorViewModel model) { InitializeComponent(); DataContext = model; }