Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
        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));
     }
 }
Exemplo n.º 5
0
 public List <BusinessArea> GetAll()
 {
     using (var ctx = new InventoryCtx())
     {
         return(ctx.BusinessAreas.ToList());
     }
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 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);
         }
     }
 }
Exemplo n.º 9
0
 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);
         }
     }
 }