public void Post([FromBody] Train newTrain) { bestdbContext context = new bestdbContext(); context.Trains.Add(newTrain); context.SaveChanges(); }
public Train Get(int id) { bestdbContext context = new bestdbContext(); var train = (from x in context.Trains where x.Id == id select x).FirstOrDefault(); return(train); }
public void Delete(int id) { bestdbContext context = new bestdbContext(); var deleteTrain = (from x in context.Trains where x.Id == id select x).FirstOrDefault(); context.Trains.Remove(deleteTrain); context.SaveChanges(); }
public int GetCount() { bestdbContext context = new bestdbContext(); return(context.Trains.Count()); }
public IEnumerable <Train> Get() { bestdbContext context = new bestdbContext(); return(context.Trains.ToList()); }