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 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 Insert(BusinessArea item) { using (var ctx = new InventoryCtx()) { ctx.BusinessAreas.Add(item); try { ctx.SaveChanges(); RaiseCollectionChanged(NotifyCollectionChangedAction.Add); return(true); } catch (Exception) { return(false); } } }