public bool Update(BusinessArea item) { using (var ctx = new InventoryCtx()) { var ItemToUpdate = ctx.BusinessAreas.Find(item.ID); if (ItemToUpdate != null) { ctx.Entry(ItemToUpdate).CurrentValues.SetValues(item); try { ctx.SaveChanges(); RaiseCollectionChanged(NotifyCollectionChangedAction.Replace); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Delete(int id) { using (var ctx = new InventoryCtx()) { var ItemToDelete = ctx.BusinessAreas.Find(id); if (ItemToDelete != null) { ctx.BusinessAreas.Remove(ItemToDelete); try { ctx.SaveChanges(); RaiseCollectionChanged(NotifyCollectionChangedAction.Remove); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public List <InventoryItem> GetAll() { using (var ctx = new InventoryCtx()) { return(ctx.InventoryItems.ToList()); } }
public InventoryItem Find(int id) { using (var ctx = new InventoryCtx()) { return(ctx.InventoryItems.Find(id)); } }
public List <BusinessArea> GetAll() { using (var ctx = new InventoryCtx()) { return(ctx.BusinessAreas.ToList()); } throw new NotImplementedException(); }
public BusinessArea Find(int id) { using (var ctx = new InventoryCtx()) { ctx.Configuration.LazyLoadingEnabled = false; return(ctx.BusinessAreas.Find(id)); } }
private static void BuildBusinessAreasTable(DataTable table) { using (var ctx = new InventoryCtx()) { var areas = ctx.BusinessAreas.ToList(); foreach (var item in areas) { table.Rows.Add(item.ID, item.Name, item.SubCategory); } } }
private static void BuildInventoryTable(DataTable table) { using (var ctx = new InventoryCtx()) { var items = ctx.InventoryItems.Include("Area").ToList(); foreach (var item in items) { table.Rows.Add(item.ID, item.Name, item.Description, item.Packaging, item.Weight, item.Cost, item.IsInternalUseOnly, item.Area.ID); } } }
public bool Insert(BusinessArea item) { using (var ctx = new InventoryCtx()) { ctx.BusinessAreas.Add(item); try { ctx.SaveChanges(); RaiseCollectionChanged(NotifyCollectionChangedAction.Add); return(true); } catch (Exception) { return(false); } } }
public bool Insert(InventoryItem item) { using (var ctx = new InventoryCtx()) { ctx.InventoryItems.Add(item); try { ctx.InventoryItems.Add(item); RaiseCollectionChanged(NotifyCollectionChangedAction.Add); return(true); } catch (Exception) { return(false); } } }