public IHttpActionResult GetSection(string sectionCodeAtPointA, string sectionCodeAtPointB) { using (var dbContext = new Kapsch.RTE.Data.DataContext()) { var item = dbContext.DotSectionConfigurations.FirstOrDefault(c => c.SectionCodePointA == sectionCodeAtPointA && c.SectionCodePointB == sectionCodeAtPointB); if (item == null) { return(this.BadRequestEx(Error.SectionConfigurationDoesNotExist)); } var model = new SectionConfigurationModel { LevenshteinMatchDistance = item.LevenshteinMatchDistance, CreatePhysicalInfringement = item.CreatePhysicalInfringement == 1, SectionCodePointA = item.SectionCodePointA, SectionCodePointB = item.SectionCodePointB, SectionCode = item.SectionCode, SectionDescription = item.SectionDescription, SectionDistanceInMeter = item.SectionDistance }; return(Ok(model)); } }
private SectionConfigurationModel GetSectionByCode(string sectionCodeAtPointA, string sectionCodeAtPointB) { using (var dbContext = new Kapsch.RTE.Data.DataContext()) { var item = dbContext.DotSectionConfigurations.FirstOrDefault(c => c.SectionCodePointA == sectionCodeAtPointA && c.SectionCodePointB == sectionCodeAtPointB); if (item != null) { SectionConfigurationModel model = new SectionConfigurationModel { LevenshteinMatchDistance = item.LevenshteinMatchDistance, CreatePhysicalInfringement = bool.Parse(item.CreatePhysicalInfringement.ToString()), SectionCodePointA = item.SectionCodePointA, SectionCodePointB = item.SectionCodePointB, SectionCode = item.SectionCode, SectionDescription = item.SectionDescription, SectionDistanceInMeter = item.SectionDistance }; return(model); } } return(null); }