Exemplo n.º 1
0
 // Trip Photos
 public IEnumerable <TripFoto> GetTripFotosByTripId(Guid tripId)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.TripFotos.Select(t => t).Where(p => p.TripId == tripId && p.IsActive).OrderBy(t => t.Sort).ToList());
     }
 }
Exemplo n.º 2
0
 public IEnumerable <TypeOfTrip> GetTypesOfTripList()
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.TripTypes.Select(a => a).OrderBy(a => a.Name).ToList());
     }
 }
Exemplo n.º 3
0
 public TypeOfTrip GetTypeOfTripById(Guid Id)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.TripTypes.FirstOrDefault(a => a.Id == Id));
     }
 }
Exemplo n.º 4
0
 public IEnumerable <Destination> GetDestinationsList()
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.Destinations.Select(a => a).OrderBy(a => a.Name).ToList());
     }
 }
Exemplo n.º 5
0
 public Activity GetActivityById(Guid Id)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.Activities.FirstOrDefault(a => a.Id == Id));
     }
 }
Exemplo n.º 6
0
 public Destination GetDestinationById(Guid Id)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.Destinations.FirstOrDefault(a => a.Id == Id));
     }
 }
Exemplo n.º 7
0
 public IEnumerable <Activity> GetActivitiesList()
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.Activities.Where(a => a.IsActive).OrderBy(a => a.Name).ToList());
     }
 }
Exemplo n.º 8
0
 // Program Days
 public IEnumerable <TripProgram> GetProgramDaysByTripId(Guid tripId)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         var d = db.TripPrograms.Select(t => t).Where(p => p.TripId == tripId && p.IsActive).OrderBy(t => t.DayNumber).ToList();
         return(d);
     }
 }
Exemplo n.º 9
0
 public Trip GetTripById(Guid Id)
 {
     using (TripsDbContext db = new TripsDbContext())
     {
         return(db.Trips
                .Include(t => t.Activity)
                .Include(t => t.Destination)
                .Include(t => t.TypeOfTrip)
                .FirstOrDefault(t => t.Id == Id));
     }
 }
Exemplo n.º 10
0
        public IEnumerable <TypeOfTrip> DeleteTypeOfTrip(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTypeOfTrip = db.TripTypes.FirstOrDefault(t => t.Id == Id);
                currentTypeOfTrip.IsActive = false;
                db.SaveChanges();

                return(db.TripTypes.Select(a => a).OrderBy(a => a.Name).ToList());
            }
        }
Exemplo n.º 11
0
        public TripFoto DeleteTripFoto(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTripFoto = db.TripFotos.FirstOrDefault(t => t.Id == Id);
                currentTripFoto.IsActive = false;
                db.SaveChanges();

                return(currentTripFoto);
            }
        }
Exemplo n.º 12
0
        //public Trip ConvertToTripModel(TripRequest tripRequest)
        //{
        //    //using (TripsDbContext db = new TripsDbContext())
        //    //{
        //    //    Guid destinationId = new Guid();
        //    //    var destination = new Destination();
        //    //    if (!string.IsNullOrEmpty(tripRequest.DestinationId))
        //    //    {
        //    //        destinationId = Guid.Parse(tripRequest.DestinationId);
        //    //        destination = db.Destinations.FirstOrDefault(d => d.Id == destinationId);
        //    //    }


        //    //    var activity = new Activity();
        //    //    if (!string.IsNullOrEmpty(tripRequest.ActivityId))
        //    //    {

        //    //        activity =
        //    //    }

        //    //    Guid typeOfTripId = new Guid();
        //    //    var typeOfTrip = new TypeOfTrip();
        //    //    if (!string.IsNullOrEmpty(tripRequest.TypeOfTripId))
        //    //    {
        //    //        typeOfTripId = Guid.Parse(tripRequest.TypeOfTripId);
        //    //        typeOfTrip = db.TripTypes.FirstOrDefault(d => d.Id == typeOfTripId);
        //    //    }



        //    //    //newTrip.Activities.Add(activity);
        //    //    //newTrip.Destinations.Add(destination);
        //    //    //newTrip.TypesOfTrip.Add(typeOfTrip);

        //    //    return newTrip;
        //    //}
        //}

        public IEnumerable <Trip> DeleteTrip(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTrip = db.Trips.FirstOrDefault(t => t.Id == Id);
                currentTrip.IsActive = false;
                db.SaveChanges();

                return(db.Trips.Select(t => t).Where(t => t.IsActive).OrderByDescending(t => t.StartDate).ToList());
            }
        }
Exemplo n.º 13
0
        public IEnumerable <Destination> DeleteDestination(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentDestination = db.Destinations.FirstOrDefault(t => t.Id == Id);
                currentDestination.IsActive = false;
                db.SaveChanges();

                return(db.Destinations.Select(a => a).OrderBy(a => a.Name).ToList());
            }
        }
Exemplo n.º 14
0
        public IEnumerable <Activity> DeleteActivity(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentActivity = db.Activities.FirstOrDefault(t => t.Id == Id);
                currentActivity.IsActive = false;
                db.SaveChanges();

                return(db.Activities.Select(a => a).Where(a => a.IsActive).OrderBy(a => a.Name).ToList());
            }
        }
Exemplo n.º 15
0
        public TripProgram DeleteProgramDay(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentprogramDay = db.TripPrograms.FirstOrDefault(t => t.Id == Id);
                currentprogramDay.IsActive = false;

                db.SaveChanges();

                return(currentprogramDay);
            }
        }
Exemplo n.º 16
0
        public Activity CreateActivity(Activity newActivity)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                newActivity.Id       = Guid.NewGuid();
                newActivity.IsActive = true;
                db.Activities.Add(newActivity);
                db.SaveChanges();

                return(newActivity);
            }
        }
Exemplo n.º 17
0
        public TripPriceDesc DeleteTripPriceDesc(Guid Id)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTripPriceDesc = db.TripPriceDescs.FirstOrDefault(t => t.Id == Id);
                currentTripPriceDesc.IsActive = false;

                db.SaveChanges();

                return(currentTripPriceDesc);
            }
        }
Exemplo n.º 18
0
        public TripFAQ CreateTripFAQ(TripFAQ tripFAQ)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                tripFAQ.Id       = Guid.NewGuid();
                tripFAQ.IsActive = true;
                db.TripFAQs.Add(tripFAQ);
                db.SaveChanges();

                return(tripFAQ);
            }
        }
Exemplo n.º 19
0
        public TripFoto CreateTripFoto(TripFoto tripFoto)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                tripFoto.Id       = Guid.NewGuid();
                tripFoto.IsActive = true;
                db.TripFotos.Add(tripFoto);
                db.SaveChanges();

                return(tripFoto);
            }
        }
Exemplo n.º 20
0
        public TripProgram CreateProgramDay(TripProgram programDay)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                programDay.Id       = Guid.NewGuid();
                programDay.IsActive = true;
                db.TripPrograms.Add(programDay);
                db.SaveChanges();

                return(programDay);
            }
        }
Exemplo n.º 21
0
        public TypeOfTrip CreateTypeOfTrip(TypeOfTrip newTypeOfTrip)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                newTypeOfTrip.Id       = Guid.NewGuid();
                newTypeOfTrip.IsActive = true;
                db.TripTypes.Add(newTypeOfTrip);
                db.SaveChanges();

                return(newTypeOfTrip);
            }
        }
Exemplo n.º 22
0
        public IEnumerable <KeyValuePair <Guid, string> > GetKeyValueDestinationsList()
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var entitiesList = db.Destinations
                                   .Where(a => a.IsActive)
                                   .Select(a => new { a.Id, a.Name })
                                   .OrderBy(a => a.Name).ToDictionary(x => x.Id, x => x.Name).ToList();

                return(entitiesList);
            }
        }
Exemplo n.º 23
0
        public TripPriceDesc CreateTripPriceDesc(TripPriceDesc tripPriceDesc)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                tripPriceDesc.Id       = Guid.NewGuid();
                tripPriceDesc.IsActive = true;
                db.TripPriceDescs.Add(tripPriceDesc);
                db.SaveChanges();

                return(tripPriceDesc);
            }
        }
Exemplo n.º 24
0
        public Destination CreateDestination(Destination newDestination)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                newDestination.Id       = Guid.NewGuid();
                newDestination.IsActive = true;
                db.Destinations.Add(newDestination);
                db.SaveChanges();

                return(newDestination);
            }
        }
Exemplo n.º 25
0
        public TripProgram UpdateProgramDay(TripProgram programDay)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentprogramDay = db.TripPrograms.FirstOrDefault(t => t.Id == programDay.Id);
                currentprogramDay.DayNumber   = programDay.DayNumber;
                currentprogramDay.Description = programDay.Description;
                currentprogramDay.Title       = programDay.Title;
                currentprogramDay.TripId      = programDay.TripId;
                currentprogramDay.IsActive    = programDay.IsActive;

                return(currentprogramDay);
            }
        }
Exemplo n.º 26
0
        public TripFAQ UpdateTripFAQ(TripFAQ tripFAQ)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTripFAQ = db.TripFAQs.FirstOrDefault(t => t.Id == tripFAQ.Id);
                currentTripFAQ.Description = tripFAQ.Description;
                currentTripFAQ.Sort        = tripFAQ.Sort;
                currentTripFAQ.Title       = tripFAQ.Title;
                currentTripFAQ.TripId      = tripFAQ.TripId;
                currentTripFAQ.IsActive    = tripFAQ.IsActive;

                return(currentTripFAQ);
            }
        }
Exemplo n.º 27
0
        public TripFoto UpdateTripFoto(TripFoto tripFoto)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTripFoto = db.TripFotos.FirstOrDefault(t => t.Id == tripFoto.Id);
                currentTripFoto.Path     = tripFoto.Path;
                currentTripFoto.Sort     = tripFoto.Sort;
                currentTripFoto.Title    = tripFoto.Title;
                currentTripFoto.TripId   = tripFoto.TripId;
                currentTripFoto.IsActive = tripFoto.IsActive;

                return(currentTripFoto);
            }
        }
Exemplo n.º 28
0
        public TripPriceDesc UpdateTripPriceDesc(TripPriceDesc tripPriceDesc)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentTripPriceDesc = db.TripPriceDescs.FirstOrDefault(t => t.Id == tripPriceDesc.Id);
                currentTripPriceDesc.Description = tripPriceDesc.Description;
                currentTripPriceDesc.IsIncluded  = tripPriceDesc.IsIncluded;
                currentTripPriceDesc.Title       = tripPriceDesc.Title;
                currentTripPriceDesc.Sort        = tripPriceDesc.Sort;
                currentTripPriceDesc.TripId      = tripPriceDesc.TripId;
                currentTripPriceDesc.IsActive    = tripPriceDesc.IsActive;

                return(currentTripPriceDesc);
            }
        }
Exemplo n.º 29
0
        public IEnumerable <Trip> GetAllTrips()
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var m = db.Trips.Select(y => y).ToList();
                var v = db.Trips
                        .Select(t => t)
                        .Where(t => t.IsActive)
                        .Include(t => t.Activity)
                        .Include(t => t.Destination)
                        .Include(t => t.TypeOfTrip)
                        .OrderByDescending(t => t.StartDate).ToList();

                return(v);
            }
        }
Exemplo n.º 30
0
        public Destination UpdateDestination(Destination activity)
        {
            using (TripsDbContext db = new TripsDbContext())
            {
                var currentDestination = db.Destinations.FirstOrDefault(t => t.Id == activity.Id);
                currentDestination.Description    = activity.Description;
                currentDestination.ImagePath      = activity.ImagePath;
                currentDestination.Name           = activity.Name;
                currentDestination.ParentId       = activity.ParentId;
                currentDestination.SeoDescription = activity.SeoDescription;
                currentDestination.SeoKeywords    = activity.SeoKeywords;
                currentDestination.Url            = activity.Url;
                db.SaveChanges();

                return(currentDestination);
            }
        }