public SchedulesModel GetSchedules(SchedulesRequestModel model) { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var context = new SofiaTransportContext(); int selectedTypeId = 1; if (model.SelectedTypeId == 1) { //tram selectedTypeId = 3; } else if (model.SelectedTypeId == 2) { selectedTypeId = 2; //trolei } var transports = context.Transport; var directions = context.Directions; var stops = context.Stops; var stopNames = context.StopName; var transport = (from t in transports where t.Type == selectedTypeId && t.Name == model.SelectedNumber select t).FirstOrDefault(); string transportId = ""; string directionId = ""; string stopId = ""; if (transport != null) { transportId = transport.SiteId; directionId = transport.Directions.First().DirectionId; stopId = (from s in stops where s.Id == model.StopId select s.StopId).First(); var response = GetSchedulesFromSite(transportId, directionId, stopId, selectedTypeId); return response; } return new SchedulesModel(); }); return responseMsg; }
public List<string> GetNames() { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var context = new SofiaTransportContext(); var transports = context.Transport; var directions = context.Directions; var stops = context.Stops; var stopNames = context.StopName; var response = (from n in stopNames select n.Name).ToList(); return response; }); return responseMsg; }
public List<RelationResponse> GetRelations() { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var context = new SofiaTransportContext(); var transports = context.Transport; var directions = context.Directions; var stops = context.Stops; var stopNames = context.StopName; var response = (from s in stops select new RelationResponse() { Name = s.Name.Id, PublicId = s.PublicId }).ToList(); return response; }); return responseMsg; }
public List<LineResponse> GetDataType3() { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var context = new SofiaTransportContext(); var transports = context.Transport; var directions = context.Directions; var stops = context.Stops; var stopNames = context.StopName; List<string> listOfStopsStrings = (from t in transports where t.Type == 3 from d in t.Directions select d.DirectionStops).ToList(); var response = (from t in transports where t.Type == 3 select new LineResponse() { Name = t.Name, DirectionResponces = (from d in t.Directions select new DirectionResponse() { FirstStop = d.FirstStop.Id, LastStop = d.LastStop.Id //, //StopsIds = (from id in d.DirectionStops.Split(',') // select int.Parse(id)) /*(from s in d.Stops select s.Id)*/ }) }).ToList(); int index = 0; for (int i = 0; i < response.Count(); i++) { foreach (var dir in response[i].DirectionResponces) { var splited = listOfStopsStrings[index++].Split(',').Select(t => int.Parse(t)); dir.StopsIds = splited; } } return response; }); return responseMsg; }