public void UpdateDocumentById(WareHouseDocument wareHouseDocument) { WareHouseDocument toUpdate = context.WareHouseDocuments .Where(x => x.WareHouseDocumentId == wareHouseDocument.WareHouseDocumentId).First(); toUpdate = wareHouseDocument; context.SaveChanges(); }
public DocumentPropertiesWindow() { InitializeComponent(); this._wareHouseDocument = new WareHouseDocument(); this._wareHouseDocument.Items = new List <Item>(); UpdateButton.Enabled = false; DeleteButton.Enabled = false; }
public void DeleteDocument(Guid wareHouseDocumentId) { WareHouseDocument wareHouseDocumentToDelete = context.WareHouseDocuments.Where(x => x.WareHouseDocumentId == wareHouseDocumentId).First(); DeleteItemsOfDocument(wareHouseDocumentToDelete); context.WareHouseDocuments .Attach(wareHouseDocumentToDelete); context.WareHouseDocuments .Remove(wareHouseDocumentToDelete); context.SaveChanges(); }
public void DeleteItemsOfDocument(WareHouseDocument wareHouseDocument) { wareHouseDocument.Items.ToList().ForEach(x => context.Items.Attach(x)); wareHouseDocument.Items.ToList().ForEach(x => context.Items.Remove(x)); context.SaveChanges(); }
public void CreateNewDocument(WareHouseDocument wareHouseDocument) { context.WareHouseDocuments.Add(wareHouseDocument); context.SaveChanges(); }
public DocumentPropertiesWindow(WareHouseDocument wareHouseDocument) { InitializeComponent(); this._wareHouseDocument = wareHouseDocument; CreateButton.Enabled = false; }