protected override bool IsValid(PropertyValidatorContext context) { // string email = context.PropertyValue as string; InputGuideTownDto m = context.Instance as InputGuideTownDto; return(_IGuideTownService.IsIdExist(m.Id)); }
// [ResponseCodes(HttpStatusCode.OK, HttpStatusCode.NotAcceptable, HttpStatusCode.Unauthorized)] public int AddTown([FromBody] InputGuideTownDto dto) { var t = _iGuideTownService.Add(CurrentLanguage, dto); if (t != null) { return((int)t); } else { throw new HttpResponseException(NotFoundMessage(CityAndTown.TownNameNotExist)); } }
public bool?Edit(LanguageHelper Language, InputGuideTownDto dto) { GuideTown T = _unitOfWork.GuideTownRepository.FindById(dto.Id); T.GuideTownDescriptions = new List <GuideTownDescription>(); T.CityId = dto.CityId; foreach (var Tdes in T.GuideTownDescriptions) { if (Tdes.LanguageId == (int)LanguageHelper.ARABIC) { Tdes.Name = dto.ArabicTownName; } else if (Tdes.LanguageId == (int)LanguageHelper.ENGLISH) { Tdes.Name = dto.EnglishTownName; } } var cityName = _unitOfWork.GuideCityDescriptionRepository.FindBy(m => m.CityId == T.CityId).Where(v => v.LanguageId == (int)LanguageHelper.ARABIC).ToList()[0].Name; GPS.GetGps townGps = new GPS.GetGps(cityName, dto.ArabicTownName); if (townGps.latitude == 0 || townGps.longitude == 0) { return(null); } try { T.Gps_Latitude = townGps.latitude.ToString(); T.Gps_Longitude = townGps.longitude.ToString(); // T.Place_Id = GPS.GetGps.Get_PlaceId_And_Town(T.Gps_Latitude.ToString() + "," + T.Gps_Longitude.ToString()).ToList()[0]; // T.TownDescriptions.Add(ETdes); _unitOfWork.GuideTownRepository.Update(T); _unitOfWork.SaveChanges(); return(true); } catch { return(false); } }
public int?Add(LanguageHelper Language, InputGuideTownDto dto) { var model = Mapper.Map <InputGuideTownDto, GuideTown>(dto); model.GuideTownDescriptions = new List <GuideTownDescription>(); GuideTownDescription ATdes = new GuideTownDescription(); ATdes.TownId = model.Id; ATdes.LanguageId = (int)LanguageHelper.ARABIC; ATdes.Name = dto.ArabicTownName; model.GuideTownDescriptions.Add(ATdes); GuideTownDescription ETdes = new GuideTownDescription(); ETdes.LanguageId = (int)LanguageHelper.ENGLISH; ETdes.Name = dto.EnglishTownName; var cityName = _unitOfWork.GuideCityDescriptionRepository.FindBy(m => m.CityId == model.CityId).Where(v => v.LanguageId == (int)LanguageHelper.ARABIC).ToList()[0].Name; GPS.GetGps townGps = new GPS.GetGps(cityName, dto.ArabicTownName); if (townGps.latitude == 0 || townGps.longitude == 0) { return(null); } try { model.Gps_Latitude = townGps.latitude.ToString(); model.Gps_Longitude = townGps.longitude.ToString(); // model.Place_Id = GPS.GetGps.Get_PlaceId_And_Town(model.Gps_Latitude.ToString() + "," + model.Gps_Longitude.ToString()).ToList()[0]; model.GuideTownDescriptions.Add(ETdes); _unitOfWork.GuideTownRepository.Add(model); _unitOfWork.SaveChanges(); return(model.Id); } catch { return(null); } }