public int SaveStations(Directory_Stations Directory_Stations) { try { ef_station.AddOrUpdate(Directory_Stations); ef_station.Save(); return(ef_station.Refresh(Directory_Stations).id); } catch (Exception e) { e.ExceptionMethodLog(String.Format("SaveStations(Directory_Stations={0})", Directory_Stations), this.servece_owner, this.eventID); return(-1); } }
/// <summary> /// Получить внутренюю дорогу по внешней станции /// </summary> /// <param name="station"></param> /// <returns></returns> public Directory_InternalRailroad GetDirectory_InternalRailroadOfStation(Directory_Stations station) { try { if (station == null) { return(null); } return(ef_irw.Context.Where(i => i.id == station.id_ir).FirstOrDefault()); } catch (Exception e) { e.ExceptionLog(String.Format("GetDirectory_InternalRailroadOfStation(station={0})", station), this.servece_owner, this.eventID); return(null); } }
/// <summary> /// Вернуть строку станции по скорректированному коду c проверкой текущего кода или нет (добавляем в конец вариант 0..9) /// </summary> /// <param name="code"></param> /// <returns></returns> public Directory_Stations GetCorrectStationsOfCode(int code, bool check) { try { Directory_Stations ref_station = null; if (check) { ref_station = GetStationsOfCode(code); } if (ref_station == null) { ref_station = GetStationsOfCode(code * 10, (code * 10) + 9).FirstOrDefault(); } return(ref_station); } catch (Exception e) { e.ExceptionMethodLog(String.Format("GetCorrectStationsOfCode(code={0})", code), this.servece_owner, this.eventID); return(null); } }
public IHttpActionResult GetStationsOfCodeCS(int code) { try { Directory_Stations station = this.ef_st.Context.Where(s => s.code_cs == code) .ToList(). Select(s => new Directory_Stations { id = s.id, code = s.code, code_cs = s.code_cs, station = s.station, id_ir = s.id_ir, }) .FirstOrDefault(); return(Ok(station)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public int GetCodeCSCorrectStations(int code, bool check) { Directory_Stations ref_station = GetCorrectStationsOfCode(code, check); return(ref_station != null && ref_station.code_cs != null ? (int)ref_station.code_cs : code); }