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); }
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(); }
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(); }
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); }