/// <summary> /// Initializes a new instance of the <see cref="TrainLine"/> class. /// </summary> /// <param name="trainLN">The line's number.</param> /// <param name="typeOT">The type of train.</param> /// <param name="direct">The direction.</param> /// <param name="period_">The time period.</param> public TrainLine(int trainLN, TypeOfTrain typeOT, Direction direct, Period period_) { setDefaultValue(); trainLineNumber = trainLN; typeOfTrain = typeOT; direction = direct; period = period_; }
public ActionResult DeleteType(int TypeId, TypeOfTrain deletedType) { var type = db.TypeOfTrains.SingleOrDefault(t => t.ID == TypeId); db.TypeOfTrains.Remove(type); db.SaveChanges(); return(RedirectToAction("ShowTypes")); }
public ActionResult EditType(int TypeId, TypeOfTrain updatedType) { var type = db.TypeOfTrains.SingleOrDefault(t => t.ID == TypeId); type.Name = updatedType.Name; db.SaveChanges(); return(RedirectToAction("ShowTypes")); }
public ActionResult AddType(TypeOfTrain typeOfTrain) { if (ModelState.IsValid == true) { TypeOfTrain NewType = new TypeOfTrain(); NewType.Name = typeOfTrain.Name; db.TypeOfTrains.Add(NewType); db.SaveChanges(); return(RedirectToAction("ShowTypes")); } return(View(typeOfTrain)); }
/// <summary> /// Updates the relative train stops' information. /// </summary> //public void updateDifferentialTrainStopInformation() //{ //} #endregion #region Private Methods /// <summary> /// Sets the default value of private fields. /// </summary> private void setDefaultValue() { trainLineNumber = 0; trainStops = new List <TrainStop>(); typeOfTrain = TypeOfTrain.Os; direction = Direction.Forward; period = Period.interval60; connectedTrainLInes = new List <TrainLine>(); originalDepartureFromFirstStation = Time.MinValue; connectedLineShift = Time.MinValue; transfersOnThisLine = new List <Transfer>(); transfersOffThisLine = new List <Transfer>(); }
/// <summary> /// Constructor with parametrs /// </summary> /// <param name="first">First route station</param> /// <param name="last">Last route station</param> /// <param name="w">Number of wagons</param> /// <param name="num">Train`s identify number</param> /// <param name="tot">Type of train</param> public Train(Station first, Station last, int w, int num, int tot) { try { if (w <= 0) throw new Exception("Error: you can`t create train without wagons"); if (tot < 0 || tot > 4) throw new ArgumentOutOfRangeException("type of train"); FirstStation = first.Name; LastStation = last.Name; Wagon = w; Number = num; Type = (TypeOfTrain)tot; } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }