/* * make for postman */ public async Task <string> AddTuristPlace(AddPlaceInputDto addinput) { var findcity = await FindCity(addinput.CityName); var findcountry = await FindCountry(addinput.Country); var cityofcountry = CityRepository.GetQuery().Include(c => c.Country) .FirstOrDefault(c => c.Country.Name == findcountry.Name && c.Name == findcity.Name); if (cityofcountry == null) { throw new KeyNotFoundException("این شهر برای این کشور نیست"); } var newplace = new TuristPlace() { Name = addinput.Name, CityId = findcity.Id, CountryId = findcity.Country.Id, Description = addinput.Description, Image = addinput.Image, Visit = 0 }; await IsRepited(newplace); TuristPlaceRepository.Insert(newplace); await TuristPlaceRepository.Save(); return("we add your place"); }
private async Task IsRepited(TuristPlace place) { var places = await TuristPlaceRepository.GetAll(); var repit = places.Find(p => p.Name == place.Name); if (repit != null) { throw new ReapitException("this place already exist"); } }
private async Task <TuristPlaceCategory> FindRegister(Category category, TuristPlace turistPlace) { var alltristplacecategory = await TuristPlaceCategoryRepository.GetAll(); var relation = alltristplacecategory.Find(a => a.TuristPlaceId == turistPlace.Id && a.CategoryId == category.Id); if (relation == null) { throw new KeyNotFoundException("Not found this relation"); } return(relation); }