Пример #1
0
 public ViewTrip CreateTrip(ViewTrip viewTrip)
 {
     using (OnATripEntities tr = new OnATripEntities())
     {
         Trip dbTrip = tr.Trips.Add(Mapper.Map<Trip>(viewTrip));
         tr.SaveChanges();
         viewTrip.TripId = dbTrip.TripId;
     }
     return viewTrip;
 }
Пример #2
0
 public ViewTrip UpdateTrip(ViewTrip viewTrip, int id)
 {
     using (OnATripEntities tr = new OnATripEntities())
     {
         Trip dbTrip = tr.Trips.Where(trp => trp.TripId == viewTrip.TripId).Select(trp => trp).FirstOrDefault();
         Mapper.Map(viewTrip, dbTrip);
         tr.SaveChanges();
         viewTrip.TripId = dbTrip.TripId;
     }
     return viewTrip;
 }
Пример #3
0
 public ViewTrip GetTrip(int tripId)
 {
     ViewTrip trip = new ViewTrip();
     using (OnATripEntities tr = new OnATripEntities())
     {
         Trip dbTrip = tr.Trips.Where(trp => trp.TripId == tripId).Select(trp => trp).FirstOrDefault();
         Mapper.Map(dbTrip, trip);
         ICollection<Activity> dbActivity = (from a in tr.Activities where a.TripID == tripId select a).ToList();
         trip.activity = Mapper.Map <ICollection<ViewActivity>>(dbActivity);
     }
     return trip;
 }
Пример #4
0
 public IHttpActionResult CloneTrip(int id, ViewTrip trip)
 {
     int userId = 1; // uzivatel se pak vezme z application user - prihlaseneho uzivatele
     tripRepo.CloneTrip(id, userId, trip.startDate);
     return Ok();
 }
Пример #5
0
 public ViewTrip UpdateTrip(int id, ViewTrip viewTrip)
 {
     return tripRepo.UpdateTrip(viewTrip,id);
 }
Пример #6
0
 public ViewTrip CreateTrip(ViewTrip viewTrip)
 {
     return tripRepo.CreateTrip(viewTrip);
 }