Example #1
0
 public void Insert(Group group)
 {
     try
     {
         using (AssociationDbContext context = new AssociationDbContext())
         {
             context.Groups.Add(group);
             context.SaveChanges();
         };
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             foreach (var ve in eve.ValidationErrors)
             {
             }
         }
         throw;
     }
     catch
     {
         throw;
     }
 }
 public void Delete(Location location)
 {
     using (AssociationDbContext context = new AssociationDbContext())
     {
         context.Entry(location).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #3
0
 public void Delete(Group group)
 {
     using (AssociationDbContext context = new AssociationDbContext())
     {
         context.Entry(group).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
 public void Delete(FixedAsset fixedAsset)
 {
     using (AssociationDbContext context = new AssociationDbContext())
     {
         context.Entry(fixedAsset).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #5
0
 public void Delete(Barcode barcode)
 {
     using (AssociationDbContext context = new AssociationDbContext())
     {
         context.Entry(barcode).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
        public IEnumerable <FixedAsset> Gets(Expression <Func <FixedAsset, bool> > predicate)
        {
            List <FixedAsset> list = new List <FixedAsset>();

            using (AssociationDbContext context = new AssociationDbContext())
            {
                list = context.FixedAssets.AsExpandable().Where(predicate).ToList();
            }
            return(list);
        }
        public IEnumerable <FixedAsset> GetAll()
        {
            List <FixedAsset> list = new List <FixedAsset>();

            using (AssociationDbContext context = new AssociationDbContext())
            {
                list = context.FixedAssets.ToList();
            }
            return(list); throw new NotImplementedException();
        }
Example #8
0
        public IEnumerable <Group> GetAll()
        {
            List <Group> list = new List <Group>();

            using (AssociationDbContext context = new AssociationDbContext())
            {
                list = context.Groups.ToList();
            }
            return(list); throw new NotImplementedException();
        }
Example #9
0
        public IEnumerable <Group> Gets(Expression <Func <Group, bool> > predicate)
        {
            List <Group> list = new List <Group>();

            using (AssociationDbContext context = new AssociationDbContext())
            {
                list = context.Groups.AsExpandable().Where(predicate).ToList();
            }
            return(list);
        }
Example #10
0
 public void Create(Group group)
 {
     try
     {
         using (AssociationDbContext context = new AssociationDbContext())
         {
             context.Groups.Add(group);
             context.SaveChanges();
         };
     }
     catch
     {
         throw;
     }
 }
        public IEnumerable <Location> Gets(Expression <Func <Location, bool> > predicate)
        {
            List <Location> list = new List <Location>();

            using (AssociationDbContext context = new AssociationDbContext())
            {
                list = context.Locations.AsExpandable().Where(predicate).ToList();
                list.ForEach(location =>
                {
                    if (Get(x => x.ParentId == location.Id) != null)
                    {
                        location.HasChild = true;
                    }
                });
            }
            return(list);
        }
        public FixedAsset Get(Expression <Func <FixedAsset, bool> > predicate)
        {
            FixedAsset fixedAsset = null;

            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    fixedAsset = context.FixedAssets.Where(predicate).FirstOrDefault();
                }
            }
            catch
            {
                throw;
            }
            return(fixedAsset);
        }
Example #13
0
        public Group Get(Expression <Func <Group, bool> > predicate)
        {
            Group group = null;

            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    group = context.Groups.Where(predicate).FirstOrDefault();
                }
            }
            catch
            {
                throw;
            }
            return(group);
        }
Example #14
0
        public Barcode Get(Expression <Func <Barcode, bool> > predicate)
        {
            Barcode barcode = null;

            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    barcode = context.Barcodes.Where(predicate).FirstOrDefault();
                }
            }
            catch
            {
                throw;
            }
            return(barcode);
        }
        public Location Get(Expression <Func <Location, bool> > predicate)
        {
            Location location = null;

            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    location = context.Locations.Where(predicate).FirstOrDefault();
                }
            }
            catch
            {
                throw;
            }
            return(location);
        }
Example #16
0
        public void Update(Barcode barcode)
        {
            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    if (context.Entry(barcode).State == EntityState.Detached)
                    {
                        context.Set <Barcode>().Attach(barcode);
                    }

                    context.Entry(barcode).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch
            {
                throw;
            }
        }
        public void Update(FixedAsset fixedAsset)
        {
            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    if (context.Entry(fixedAsset).State == EntityState.Detached)
                    {
                        context.Set <FixedAsset>().Attach(fixedAsset);
                    }

                    context.Entry(fixedAsset).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch
            {
                throw;
            }
        }
        public void Updatee(Location location)
        {
            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    if (context.Entry(location).State == EntityState.Detached)
                    {
                        context.Set <Location>().Attach(location);
                    }

                    context.Entry(location).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch
            {
                throw;
            }
        }
Example #19
0
        public void Update(Group group)
        {
            try
            {
                using (AssociationDbContext context = new AssociationDbContext())
                {
                    if (context.Entry(group).State == EntityState.Detached)
                    {
                        context.Set <Group>().Attach(group);
                    }

                    context.Entry(group).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch
            {
                throw;
            }
        }
 public CompaniesController(AssociationDbContext context, CompanyService companyService)
 {
     _context        = context;
     _companyService = companyService;
 }
 public AssociationService(AssociationDbContext context)
 {
     _context = context;
 }
Example #22
0
 public CompanyService(AssociationDbContext context)
 {
     _context = context;
 }
 public AssociatedsController(AssociationDbContext context, AssociatedService associatedService)
 {
     _context           = context;
     _associatedService = associatedService;
 }