public AutoRepairWCF GetNearestAutoRepair(string userLocation) { AutoRepairDTO autoRepairDTO = null; AutoRepairWCF autoRepairWCF = new AutoRepairWCF(); try { using (AutoRepairShopRepositoryBLL context = new AutoRepairShopRepositoryBLL()) { autoRepairDTO = context.GetNearestAutoRepair(userLocation); TranslateAutoRepairDTOToAutoRepairWCF(autoRepairDTO, autoRepairWCF); } } catch (Exception ex) { throw new FaultException <AutoRepairFault>( new AutoRepairFault { ErrorMessage = ex.Message, Source = ex.Source, StackTrace = ex.StackTrace, Target = ex.TargetSite.ToString() }, new FaultReason(string.Format(CultureInfo.InvariantCulture, "{0}", "Service fault exception: " + ex.Message))); // throw new FaultException("Service fault exception: " +ex.Message); } if (autoRepairDTO == null) { string msg = string.Format("No AutoRepairShop found for user location {0}", userLocation); throw new FaultException <AutoRepairFault>(new AutoRepairFault { ErrorMessage = msg, Source = null, StackTrace = null, Target = null }, new FaultReason(string.Format(CultureInfo.InvariantCulture, "{0}", "Service fault exception: " + msg))); } return(autoRepairWCF); }
private void TranslateAutoRepairDTOToAutoRepairWCF(AutoRepairDTO autoRepairDTO, AutoRepairWCF autoRepairWCF) { autoRepairWCF.ID = autoRepairDTO.ID; autoRepairWCF.Name = autoRepairDTO.Name; autoRepairWCF.Address = autoRepairDTO.Address; autoRepairWCF.City = autoRepairDTO.City; autoRepairWCF.Phone = autoRepairDTO.Phone; autoRepairWCF.Url = autoRepairDTO.Url; autoRepairWCF.Geolocation = autoRepairDTO.Geolocation; }