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; }
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; }
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; }
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(); }
public ViewTrip UpdateTrip(int id, ViewTrip viewTrip) { return tripRepo.UpdateTrip(viewTrip,id); }
public ViewTrip CreateTrip(ViewTrip viewTrip) { return tripRepo.CreateTrip(viewTrip); }