コード例 #1
0
        public static ProductionUnit GetProductionUnit(int?ProductionUnitId)
        {
            ProductionUnit ProductionUnit = null;

            using (SmizeeContext Context = new SmizeeContext())
            {
                ProductionUnit = Context.ProductionUnits.FirstOrDefault(cp => cp.ProductionUnitID == ProductionUnitId);
            }
            return(ProductionUnit);
        }
コード例 #2
0
        public static void CreateRecord(string description, int AreaId, int CompanyId, int SectorId, int?Hectares)
        {
            using (var db = new Models.SmizeeContext())
            {
                ProductionUnit productionUnit = db.ProductionUnits.FirstOrDefault(cp => cp.Description == description);

                if (productionUnit != null)
                {
                    throw new Exception("Duplicate Record!");
                }

                ProductionUnit entity = new ProductionUnit();
                entity.Description = description;
                entity.AreaID      = AreaId;
                entity.CompanyID   = CompanyId;
                entity.SectorID    = SectorId;
                entity.Hectares    = Hectares;

                db.ProductionUnits.Add(entity);
                db.SaveChanges();
            }
        }