public FillUp AddFillUpNoNextFillUp(int odometer, double liters) { FillUp f = new FillUp(odometer, liters); //this.FillUps.Add(f); FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters, bool isFull = true) { var fillUpItem = new FillUp(odometer, liters, isFull); if (FillUps.Count > 0) { FillUps.Last().NextFileUp = fillUpItem; } FillUps.Add(fillUpItem); return(fillUpItem); }
public FillUp AddFillUp(int odometer, double liters) { FillUp f = new FillUp(odometer, liters); if (FillUps?.Count > 0) { FillUps.LastOrDefault().NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters) { //throw new NotImplementedException(); FillUp f = new FillUp(odometer, liters); if (FillUps.Count > 0) { FillUps[FillUps.Count - 1].NextFillUp = f; } FillUps.Add(f); return(f); }
// Method public FillUp AddFillUp(int odometer, double liters) { FillUp f = new FillUp(odometer, liters); FillUp last = FillUps.LastOrDefault(); if (last != null) { last.NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters) { FillUp f = new Models.FillUp(); f.Odometer = odometer; f.Liters = liters; if (FillUps.Count > 0) { FillUps[FillUps.Count - 1].NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters) { var f = new FillUp() { Odometer = odometer, Liters = liters }; if (FillUps.Any()) { FillUps.OrderBy(x => x.Odometer).Last().NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odoMeter, double liters) { FillUp f = new FillUp(odoMeter, liters); //var prevFillUp = FillUps.LastOrDefault(); var prevFillUp = FillUps.Where(x => x.NextFillUp == null).FirstOrDefault(); if (prevFillUp != null) { prevFillUp.NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters, bool isFull = true) { var f = new FillUp(); f.Odometer = odometer; f.Liters = liters; f.IsFull = isFull; f.NextFillUp = null; if (FillUps.Count > 0) { FillUps.Last().NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double liters, bool isFull = true) { FillUp f = new FillUp(odometer, liters, isFull); if (FillUps.Count > 0) { FillUps.LastOrDefault().NextFillUp = f; } if (FillUps.Count == 0 || (FillUps.Count > 0 && FillUps.LastOrDefault().Odometer < f.Odometer)) { FillUps.Add(f); } else { throw new InvalidOperationException(); } return(f); }
public FillUp AddFillUp(int odometer, double liters) { var f = new FillUp() { Odometer = odometer, Liters = liters }; //if (FillUps.Count > 0) { // FillUps[FillUps.Count - 1].NextFillUp = f; //} if (FillUps.Any <FillUp>()) { FillUps.OrderBy(x => x.Odometer).Last().NextFillUp = f; } FillUps.Add(f); return(f); }
public FillUp AddFillUp(int odometer, double lister) { if (odometer <= 0) { throw new Exception(); } if (lister <= 0) { throw new Exception(); } var fillUp = new FillUp(odometer, lister); if (FillUps.Count > 0) { var last = FillUps.Last(); last.Next = fillUp; } FillUps.Add(fillUp); return(fillUp); }