public LineModel PostSaveDurations(SaveDurationsModel data)
        {
            LineModel res = null;

            using (var logic = new LineLogic())
            {
                var ln = logic.ReCalcTimeTable(data);
                if (ln != null)
                {
                    res = new LineModel(ln)
                    {
                        Stations = ln.StationsToLines.Select(z => new StationToLineModel(z)).ToList()
                    };
                }
            }
            return(res);
        }
        public List <StationToLineModel> PostSaveGeometry(SaveGeometryModel model)
        {
            var res = new List <StationToLineModel>();

            using (var logic = new LineLogic())
            {
                var line = logic.GetLine(model.Id);
                if (line != null)
                {
                    line.PathGeometry = model.Data;
                    logic.SaveChanges();

                    string         fs = "0:0";
                    StationsToLine st = null;
                    st = line.Direction == 0 ? line.StationsToLines.OrderBy(s => s.Position).Last() : line.StationsToLines.OrderBy(s => s.Position).First();
                    if (line.StationsToLines.Select(l => l.ArrivalDate).Max() > st.ArrivalDate && line.Direction == 0)
                    {
                        st.ArrivalDate = line.StationsToLines.Select(l => l.ArrivalDate).Max();
                    }
                    fs = st.ArrivalDate.Hours + ":" + st.ArrivalDate.Minutes;
                    var data = new SaveDurationsModel
                    {
                        LineId       = model.Id,
                        Durations    = model.Durations,
                        FirstStation = fs
                    };
                    var ln = logic.ReCalcTimeTable(data);
                    if (ln != null)
                    {
                        res = ln.StationsToLines
                              .OrderBy(z => z.Position)
                              .Select(z => new StationToLineModel(z))
                              .ToList();
                    }
                }
            }
            return(res);
        }