public List <TaxationYears> GetAllYears() { using (var context = new ConstantTrialPlotsContext()) { return(context.TaxationYear.ToList()); } }
public List <TrialPlot> GetAllTrialPlots() { using (var context = new ConstantTrialPlotsContext()) { return(context.TrialPlot.ToList()); } }
public List <TreeProperty> GetTreeProperties() { using (var context = new ConstantTrialPlotsContext()) { return(context.TreeProperty.ToList()); } }
public List <Leshos> GetAllLeshozes() { using (var context = new ConstantTrialPlotsContext()) { return(context.Leshos.ToList()); } }
public PlotInfo GetSeparatedPlotInfo(int leshosId, int plotNumber) { using (var context = new ConstantTrialPlotsContext()) { var result = context.Tree.Where(t => t.IdPlotNavigation.Number == plotNumber && t.IdPlotNavigation.IdLeshosTypeNavigation.Id == leshosId).Include(t => t.IdPlotNavigation).Include(t => t.TreeProperties).ToList(); return(SeparationPlotBuild(50, 100, result, false)); } }
public TrialPlot GetPlotInfo(int leshosId, int plotNumber) { using (var context = new ConstantTrialPlotsContext()) { return(context.TrialPlot.Where(tp => tp.IdLeshos == leshosId && tp.Number == plotNumber) .Include(t => t.Tree) .ThenInclude(t => t.IdBreedNavigation) .ThenInclude(tp => tp.Tree) .ThenInclude(tp => tp.TreeProperties) .ThenInclude(tp => tp.IdTaxationYearsNavigation) .SingleOrDefault()); } }
public Tree GetTreeInfo(int leshosId, int plotNumber, short treeNumber) { using (var context = new ConstantTrialPlotsContext()) { return(context.Tree.Include(t => t.IdPlotNavigation) .Where(t => t.IdPlotNavigation.IdLeshos == leshosId && t.IdPlotNavigation.Number == plotNumber && t.Number == treeNumber) .Include(t => t.IdBreedNavigation) .Include(t => t.TreeProperties) .ThenInclude(t => t.IdCraftNavigation) .ThenInclude(t => t.TreeProperty) .ThenInclude(t => t.IdSuitabilityNavigation) .ThenInclude(t => t.TreeProperty) .ThenInclude(t => t.IdTaxationYearsNavigation) .SingleOrDefault()); } }
private static void BuildTrialPlot(TrialPlot plot) { using (var context = new ConstantTrialPlotsContext()) { var check = context.TrialPlot.Where(p => p.Az == plot.Az && p.IdLeshos == plot.IdLeshos && p.Length == plot.Length && p.Number == plot.Number && p.Square == plot.Square && p.Weight == plot.Weight && p.X == plot.X && p.Y == plot.Y); if (check.FirstOrDefault() != null) { TrialPlot = check.FirstOrDefault(); } else { context.TrialPlot.Add(plot); TrialPlot = plot; } context.SaveChanges(); } }
private static void BuildLeshos(Leshos leshos) { using (var context = new ConstantTrialPlotsContext()) { var check = context.Leshos.Where(l => l.Kvartal == leshos.Kvartal && l.Lesnichestvo == leshos.Lesnichestvo && l.Name == leshos.Name && l.Vydel == leshos.Vydel); if (check.FirstOrDefault() != null) { Leshos = check.FirstOrDefault(); } else { context.Leshos.Add(leshos); Leshos = leshos; } context.SaveChanges(); } }
private static void BuildSpravochniki() { using (var context = new ConstantTrialPlotsContext()) { context.TechnicalSuitability.AddRange(techCategory.Where(tc => !context.TechnicalSuitability.Any(t => t.Chipher == tc.Chipher && t.Name == tc.Name))); context.СraftСategory.AddRange(craftCategory.Where(tc => !context.СraftСategory.Any(t => t.Chipher == tc.Chipher && t.Name == tc.Name))); context.Breed.AddRange(breedsCategory.Where(tc => !context.Breed.Any(t => t.Cipher == tc.Cipher && t.Name == tc.Name))); var checkYears = context.TaxationYear.Where(ty => ty.Year == TaxationYear.Year).FirstOrDefault(); if (checkYears != null) { TaxationYear = context.TaxationYear.Where(ty => ty.Year == TaxationYear.Year).FirstOrDefault(); } else { context.TaxationYear.Add(TaxationYear); } context.SaveChanges(); } }
private static ICollection <Tree> GetListTree(Range range) { List <Tree> trees = new List <Tree>(); int raw = 19; while (!((range.Cells[raw, 1] as Range).Value2 is null)) { using (var context = new ConstantTrialPlotsContext()) { var tree = new Tree() { IdPlot = TrialPlot.Id, Number = (int)(range.Cells[raw, 1] as Range).Value2, X = (double)(range.Cells[raw, 2] as Range).Value2, Y = (double)(range.Cells[raw, 3] as Range).Value2, IdBreed = context.Breed.ToList().FirstOrDefault(e => e.Cipher == (range.Cells[raw, 4] as Range).Value2).Id, }; context.Tree.Add(tree); context.SaveChanges(); var property = new TreeProperty { Age = (int)(range.Cells[raw, 6] as Range).Value2, DiametrNs = (double)(range.Cells[raw, 7] as Range).Value2, DiametrWe = (double)(range.Cells[raw, 9] as Range).Value2, Height = (double)(range.Cells[raw, 10] as Range).Value2, CrownDiametrNs = (range.Cells[raw, 11] as Range).Value2 as double?, CrownDiametrWe = (range.Cells[raw, 12] as Range).Value2 as double?, CrownLength = (range.Cells[raw, 14] as Range).Value2 as double?, IdCraft = context.СraftСategory.ToList().FirstOrDefault(c => c.Chipher == ArabToRim((int?)(range.Cells[raw, 15] as Range).Value2)).Id, IdSuitability = context.TechnicalSuitability.ToList().FirstOrDefault(t => t.Chipher == (string)(range.Cells[raw, 16] as Range).Value2).Id, IdTaxationYears = TaxationYear.Id, IdTree = tree.Id }; context.TreeProperty.Add(property); context.SaveChanges(); } raw++; } return(trees); }
public List <GeneralLeshozInfo> GetAllLeshozes() { try { using (var context = new ConstantTrialPlotsContext()) { var result = context.Leshos.Include(ls => ls.TrialPlots) .ThenInclude(t => t.Tree) .ThenInclude(t => t.IdBreedNavigation) .ThenInclude(t => t.Tree) .ThenInclude(p => p.TreeProperties) .ThenInclude(y => y.IdTaxationYearsNavigation) .ToList(); return(BuildGeneralInfo(result)); } } catch (Exception ex) { throw; } }