Example #1
0
        public void Post([FromBody] Train newTrain)
        {
            bestdbContext context = new bestdbContext();

            context.Trains.Add(newTrain);
            context.SaveChanges();
        }
Example #2
0
        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);
        }
Example #3
0
        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();
        }
Example #4
0
        public int GetCount()
        {
            bestdbContext context = new bestdbContext();

            return(context.Trains.Count());
        }
Example #5
0
        public IEnumerable <Train> Get()
        {
            bestdbContext context = new bestdbContext();

            return(context.Trains.ToList());
        }