Esempio n. 1
0
        public TourViewModel GetTour(string tourType, string countryUrl, string tourUrl)
        {
            var tourTypeDomain = TourTypesConverter.ConvertFromString(tourType);
            var tour           = _tourManager.GetTour(tourTypeDomain, countryUrl, tourUrl);
            var tourViewModel  = new TourViewModel(tour);

            return(tourViewModel);
        }
        public CountryViewModel GetCountry(string tourType, string countryUrl)
        {
            var tourTypeDomain   = TourTypesConverter.ConvertFromString(tourType);
            var country          = _countryManager.GetCountry(tourTypeDomain, countryUrl);
            var countryViewModel = new CountryViewModel(country);

            return(countryViewModel);
        }
Esempio n. 3
0
 public CountryShortViewModel(ICountry country)
 {
     CountryId          = country.CountryId;
     Name               = country.Name;
     UrlName            = country.UrlName;
     Category           = TourTypesConverter.ConvertToString(country.Category);
     ThreeStarsPrice    = country.ThreeStarsPrice;
     FourStarsPrice     = country.FourStarsPrice;
     FiveStarsPrice     = country.FiveStarsPrice;
     Description        = country.Description;
     Title              = country.Title;
     OldImageCollection = country.ImageIdCollection.ToList();
 }
        public void Post([FromBody] CountryViewModel country)
        {
            ICountry countryModel;

            try
            {
                countryModel                 = _countryManager.GetCountry(country.CountryId);
                countryModel.Name            = country.Name;
                countryModel.UrlName         = country.UrlName;
                countryModel.Category        = TourTypesConverter.ConvertFromString(country.Category);
                countryModel.ThreeStarsPrice = country.ThreeStarsPrice;
                countryModel.FourStarsPrice  = country.FourStarsPrice;
                countryModel.FiveStarsPrice  = country.FiveStarsPrice;
                countryModel.Description     = country.Description;
                countryModel.PageContent     = country.PageContent;
            }
            catch (CountryNotFoundException)
            {
                countryModel = _countryManager.CreateCountry(
                    country.Name,
                    country.UrlName,
                    TourTypesConverter.ConvertFromString(country.Category),
                    country.ThreeStarsPrice,
                    country.FourStarsPrice,
                    country.FiveStarsPrice,
                    country.Description,
                    country.PageContent
                    );
            }

            countryModel.PageContentBottom = country.PageContentBottom;
            countryModel.Title             = country.Title;
            countryModel.MetaDescription   = country.MetaDescription;
            countryModel.MetaKeywords      = country.MetaKeywords;
            countryModel.PageHeader        = country.PageHeader;

            var imageForDeleteCollection = countryModel.ImageIdCollection.Where(imageId => !country.OldImageCollection.Contains(imageId)).ToList();

            foreach (var newImage in country.NewImageCollection)
            {
                var image = CreateImage(newImage);
                countryModel.AddImage(image.ImageId);
            }

            foreach (var imageId in imageForDeleteCollection)
            {
                countryModel.DeleteImage(imageId);
            }

            countryModel.Save();
        }
Esempio n. 5
0
        public void Post([FromBody] TourViewModel tour)
        {
            ITour tourModel;

            try
            {
                tourModel                  = _tourManager.GetTour(tour.TourId);
                tourModel.Name             = tour.Name;
                tourModel.UrlName          = tour.UrlName;
                tourModel.City             = tour.City;
                tourModel.Category         = TourTypesConverter.ConvertFromString(tour.Category);
                tourModel.Price            = tour.Price;
                tourModel.Stars            = tour.Stars;
                tourModel.Description      = tour.Description;
                tourModel.Country          = tour.Country;
                tourModel.Nights           = tour.Nights;
                tourModel.IsFlightIncluded = tour.IsFlightIncluded;
            }
            catch (TourNotFoundException)
            {
                tourModel = _tourManager.CreateTour(
                    tour.Name,
                    tour.UrlName,
                    tour.City,
                    TourTypesConverter.ConvertFromString(tour.Category),
                    tour.Price,
                    tour.Stars,
                    tour.Description,
                    tour.Country,
                    tour.Nights,
                    tour.IsFlightIncluded
                    );
            }

            var imageForDeleteCollection = tourModel.ImageIdCollection.Where(imageId => !tour.OldImageCollection.Contains(imageId)).ToList();

            foreach (var newImage in tour.NewImageCollection)
            {
                var image = CreateImage(newImage);
                tourModel.AddImage(image.ImageId);
            }

            foreach (var imageId in imageForDeleteCollection)
            {
                tourModel.DeleteImage(imageId);
            }

            tourModel.Save();
        }
Esempio n. 6
0
 public TourViewModel(ITour tour)
 {
     TourId             = tour.TourId;
     Name               = tour.Name;
     UrlName            = tour.UrlName;
     City               = tour.City;
     Category           = TourTypesConverter.ConvertToString(tour.Category);
     Price              = tour.Price;
     Stars              = tour.Stars;
     Description        = tour.Description;
     Country            = tour.Country;
     Nights             = tour.Nights;
     IsFlightIncluded   = tour.IsFlightIncluded;
     NewImageCollection = new List <string>();
     OldImageCollection = tour.ImageIdCollection.ToList();
 }
 public CountryViewModel(ICountry country)
 {
     CountryId          = country.CountryId;
     Name               = country.Name;
     UrlName            = country.UrlName;
     Category           = TourTypesConverter.ConvertToString(country.Category);
     ThreeStarsPrice    = country.ThreeStarsPrice;
     FourStarsPrice     = country.FourStarsPrice;
     FiveStarsPrice     = country.FiveStarsPrice;
     Description        = country.Description;
     PageContent        = country.PageContent;
     PageContentBottom  = country.PageContentBottom;
     Title              = country.Title;
     MetaDescription    = country.MetaDescription;
     MetaKeywords       = country.MetaKeywords;
     PageHeader         = country.PageHeader;
     NewImageCollection = new List <string>();
     OldImageCollection = country.ImageIdCollection.ToList();
 }
Esempio n. 8
0
        public PageViewModel <TourViewModel> GetCollection(string tourType, string country, int skip = 0, int take = int.MaxValue)
        {
            var tourFilter = new TourFilter(skip, take)
            {
                TourType   = string.IsNullOrWhiteSpace(tourType) ? (TourTypesEnum?)null : TourTypesConverter.ConvertFromString(tourType),
                CountryUrl = country
            };
            var toursPage = _tourManager.GetToursPage(tourFilter);
            var result    = GetToursPageViewModel(toursPage);

            return(result);
        }
        public PageViewModel <CountryShortViewModel> GetCollection(string tourType, int skip = 0, int take = int.MaxValue)
        {
            var countryFilter = new CountryFilter(skip, take)
            {
                TourType = string.IsNullOrWhiteSpace(tourType) ? (TourTypesEnum?)null : TourTypesConverter.ConvertFromString(tourType)
            };
            var countriesPage = _countryManager.GetCountriesPage(countryFilter);
            var result        = GetCountriesPageViewModel(countriesPage);

            return(result);
        }