public void Delete(T entity)
        {
            InspectionProcessEntities context = CreateContext();

            context.Entry(entity).State = EntityState.Deleted;

            context.SaveChanges();
        }
        protected InspectionProcessEntities CreateContext()
        {
            InspectionProcessEntities context = new InspectionProcessEntities();

            context.Configuration.ProxyCreationEnabled = false;
            context.Database.Log = x => Console.WriteLine(x);

            return(context);
        }
        public virtual void Insert(T entity)
        {
            InspectionProcessEntities context = CreateContext();

            //context.Albums.Add(album);
            context.Entry(entity).State = EntityState.Added;

            context.SaveChanges();
        }
Exemple #4
0
        public int GetMaxId()
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.Inspections
                        orderby x.InspectionId descending
                        select x.InspectionId;

            return(query.FirstOrDefault());
        }
        public int GetbyCountDumpA()
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.Warehouses
                        where x.WarehouseId == 4
                        select x.Count;

            return(query.FirstOrDefault());
        }
        public List <Warehouse> GetbyDump()
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.Warehouses
                        where x.WarehouseId > 3
                        select x;

            return(query.ToList());
        }
Exemple #7
0
        public int GetbyId(int inspectionId)
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.Inspections
                        where x.InspectionId == inspectionId
                        select x.InspectionId;

            return(query.FirstOrDefault());
        }
Exemple #8
0
        public List <Inspection> GetAllbyDate(DateTime startDate, DateTime finishDate)
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.Inspections
                        orderby x.InspectionId descending
                        where (x.FinishTime == null || x.FinishTime != null && x.StartTime >= startDate) ||
                        (x.FinishTime <= finishDate && x.StartTime >= startDate)
                        select x;

            return(query.ToList());
        }
        public List <InspectionResult> SearchByQuality(int?inspectionId, int?productId, int?inspectionTeamId)
        {
            InspectionProcessEntities context = CreateContext();

            var query = from x in context.InspectionResults
                        select new
            {
                InspectionResult   = x,
                MerchandiseName    = x.Product.Merchandise.Name,
                InspectionTeamName = x.Inspection.Team.Name,
            };

            if (inspectionId.HasValue)
            {
                query = query.Where(x => x.InspectionResult.Inspection.InspectionId == inspectionId);
            }
            if (productId.HasValue)
            {
                query = query.Where(x => x.InspectionResult.ProductId == productId);
            }
            if (inspectionTeamId.HasValue)
            {
                query = query.Where(x => x.InspectionResult.Inspection.InspectionTeam == inspectionTeamId);
            }


            var list = query.ToList();

            foreach (var x in list)
            {
                x.InspectionResult.MerchandiseName    = x.MerchandiseName;
                x.InspectionResult.InspectionTeamName = x.InspectionTeamName;
            }

            return(list.ConvertAll(x => x.InspectionResult));
        }
Exemple #10
0
        public Inspection Get(int inspectionId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Inspections.FirstOrDefault(a => a.InspectionId == inspectionId));
        }
Exemple #11
0
        public Team Get(int teamId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Teams.FirstOrDefault(a => a.TeamId == teamId));
        }
        public Product Get(int productId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Products.FirstOrDefault(a => a.ProductId == productId));
        }
        public Keeping Get(int warehouseId, int inspectionResultId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Keepings.FirstOrDefault(a => a.WarehouseId == warehouseId && a.InspectionResultId == inspectionResultId));
        }
        public int GetCount()
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Set <T>().Count());
        }
        public List <T> GetAll()
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Set <T>().ToList());
        }
        public Warehouse Get(int warehouseId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Warehouses.FirstOrDefault(a => a.WarehouseId == warehouseId));
        }
Exemple #17
0
        public Merchandise Get(int merchandiseId)
        {
            InspectionProcessEntities context = CreateContext();

            return(context.Merchandises.FirstOrDefault(a => a.MerchandiseId == merchandiseId));
        }