private static IEnumerable<Tour> CoverYourBasesTours(List<Organization> organizations)
        {
            var tour = new Tour
            {
              Code = "CYB4NY",
              Name = "Cover Your Bases",
              Permalink = "cover-your-bases-nyc",
              IsPublished = true,
              LengthDescription = "4 day/3 night",
              DepartureCity = "New York, NY",
              ReturningCity = "New York, NY",
              AvailabilityStatusId = 3
            };

              var departures = new List<Departure>
            {
              new Departure
            {
              Code = "CYB4NY01",
              DepartureDate = new DateTime(2013, 8, 23),
              ReturnDate = new DateTime(2013, 8, 26),
              Product = CreateProduct(tour.Name, organizations, 1399.0M, 1099.0M, 899.0M, 799.0M),
              AvailabilityStatusId = 1
            }
            };

              tour.Departures = departures;
              return new[] { tour };
        }
        public void Add(TourUpdate tourUpdate)
        {
            // var category = _categoryRepo.All.Where(a => a.Id == tourUpdate.Category_Id).FirstOrDefault();
            var categories = _categoryRepo.All.Where(a => tourUpdate.SelectedCategories.Contains(a.Id));
            var tour = new Tour
            {
                Code = tourUpdate.Code,
                Name = tourUpdate.Name,
                Permalink = tourUpdate.Permalink,
                AvailabilityStatusId = tourUpdate.AvailabilityStatusId,
                TourTypeId = tourUpdate.TourTypeId,
                IsPublished = tourUpdate.IsPublished,
                LengthDescription = tourUpdate.LengthDescription,
                DepartureCity = tourUpdate.DepartureCity,
                ReturningCity = tourUpdate.ReturningCity,
                MailingListEmailName = tourUpdate.MailingListEmailName,
                MailingListUrl = tourUpdate.MailingListUrl,
                MailingListID = tourUpdate.MailingListID,
                SampleDocumentURL = tourUpdate.SampleDocumentURL

            };

            SEOTool SEOTool = new Core.Domain.SEOTool();
            SEOTool.FocusKeyword = tourUpdate.FocusKeyword;
            SEOTool.MetaDescription = tourUpdate.MetaDescription;
            SEOTool.SEOTitle = tourUpdate.SEOTitle;
            tour.SEOTools = new List<Core.Domain.SEOTool>();
            tour.SEOTools.Add(SEOTool);

            tour.Categories = new System.Collections.Generic.List<Category>();
            tour.Categories.AddRange(categories.ToList());
            _tourRepo.Add(tour);
        }
 public EmailResult StudentInquiryEmail(Tour tour, StudentInquiryForm form)
 {
     To.Add(_studentInquiryNotificationEmailAddress);
       // TODO: from address should be configurable somewhere
       From = "*****@*****.**";
       Subject = string.Format("Student Inquiry for {0}", tour.Name);
       return Email("StudentInquiry", new StudentInquiry { Tour = tour, Form = form });
 }
        public void AddExperience(Tour tour)
        {
            if (_experienceRepo.FindBy(e => e.TourId == tour.Id).Any())
                return;

            var lastPosition = 0;
            if (_experienceRepo.All.Any())
                lastPosition = _experienceRepo.All.Max(e => e.Position);
            _experienceRepo.Add(new Experience
            {
                TourId = tour.Id,
                Position = lastPosition + 1
            });
        }
        private static TourShow PopulateTourShow(Tour tour, int OrganizationId)
        {
            var tourShow = Mapper.Map<TourShow>(tour);
            var products = tour.Departures.
              Where(d => d.AvailabilityStatusId == AvailabilityStatus.Available).
              Select(d => d.Product).ToList();
            if (products.Any())
            {
                var allVariants = products.SelectMany(p => p.ProductVariants).ToList();
                if (allVariants.Any())
                {
                    tourShow.BestSinglePrice = BestPriceForVariant(allVariants, "Single", "brite");
                    tourShow.BestDoublePrice = BestPriceForVariant(allVariants, "Double", "brite");
                    tourShow.BestTriplePrice = BestPriceForVariant(allVariants, "Triple", "brite");
                    tourShow.BestQuadPrice = BestPriceForVariant(allVariants, "Quad", "brite");

                    tourShow.BriterBestSinglePrice = BestPriceForVariant(allVariants, "Single", "briter");
                    tourShow.BriterBestDoublePrice = BestPriceForVariant(allVariants, "Double", "briter");
                    tourShow.BriterBestTriplePrice = BestPriceForVariant(allVariants, "Triple", "briter");
                    tourShow.BriterBestQuadPrice = BestPriceForVariant(allVariants, "Quad", "briter");
                }
            }

            //departures filtered by organizations
            var departure = tourShow.Departures.Where(pr => pr.Organizations.Any(us => us.Id == OrganizationId));
            tourShow.Departures = departure.ToList();

            return tourShow;
        }
 public void RemoveExperience(Tour tour)
 {
     var exp = _experienceRepo.FindBy(e => e.TourId == tour.Id).SingleOrDefault();
     if (exp != null)
     {
         _experienceRepo.Delete(exp);
     }
 }
 public IQueryable<TourTimelineItem> TimelineItems(Tour tour)
 {
     return TimelineItems(tour.Id);
 }
 public IEnumerable<Departure> Departures(Tour tour)
 {
     return tour == null ? null : Departures(tour.Id);
 }
 public void SendStudentInquiry(Tour tour, StudentInquiryForm form)
 {
     // TODO: Mails are sent synchronously
       // this probably still should be refactored to use a real bg process
       _controller.StudentInquiryEmail(tour, form).Deliver();
 }