Beispiel #1
0
        public object GetById(int id)
        {
            object trip = null;

            using (var db = new TripContext())
            {
                trip = db.TripPlans.Where(x => x.Id == id).FirstOrDefault();
            }
            return(trip);
        }
Beispiel #2
0
 public void Update(object obj)
 {
     using (var db = new TripContext())
     {
         try
         {
             db.TripPlans.Add((TripPlan)obj);
             db.SaveChanges();
         }
         catch
         {
             throw;
         }
     }
 }
Beispiel #3
0
        public void Remove(int id)
        {
            var entity = GetById(id);

            using (var db = new TripContext())
            {
                try
                {
                    db.TripPlans.Remove((TripPlan)entity);
                    db.SaveChanges();
                }
                catch
                {
                    throw;
                }
            }
        }
Beispiel #4
0
        public IEnumerable <object> GetAll()
        {
            IEnumerable <object> trips;

            using (var db = new TripContext())
            {
                try
                {
                    trips = db.TripPlans.ToList();
                }
                catch
                {
                    trips = new List <object>();
                }
            }
            return(trips);
        }