/// <summary> /// Queries the DB using the existing ReadOrgUnitHandler /// </summary> private ReadOrgUnitResponse QueryData(ConvertServiceRequest request) { var detailRequest = new ReadOrgUnitRequest(_orgUnitId); return ProcessRequest<ReadOrgUnitResponse>(detailRequest); }
private string GetLocation(ConvertServiceRequest request) { var orgUnitId = 0; if (request.Parameters.ContainsKey("externalId")) { orgUnitId = LookupDataEntityMapId(request.Parameters["externalId"], false); } else if (request.Parameters.ContainsKey("id")) { if (!int.TryParse(request.Parameters["id"], out orgUnitId)) throw new BusinessException("Org Unit Id must be a valid integer"); } var getOrgUnitRequest = new ReadOrgUnitPublishedRequestV2 { Id = orgUnitId }; var orgUnit = ProcessRequest<ReadOrgUnitPublishedResponseV2>(getOrgUnitRequest).OrgUnit; var viewModel = new OrgUnitV2 { OrgUnitInternalId = orgUnit.Id.ToString(CultureInfo.InvariantCulture), OrgUnitExternalId = orgUnit.ExternalId, Name = orgUnit.Name, IsEnabled = orgUnit.IsEnabled.ToString(CultureInfo.InvariantCulture), Address1 = orgUnit.Address1, Address2 = orgUnit.Address2, City = orgUnit.City, State = orgUnit.StateName, Country = orgUnit.CountryName, PostalCode = orgUnit.PostalCode, Latitude = orgUnit.Latitude.HasValue ? orgUnit.Latitude.Value.ToString(CultureInfo.InvariantCulture) : null, Longitude = orgUnit.Longitude.HasValue ? orgUnit.Longitude.Value.ToString(CultureInfo.InvariantCulture) : null, Phone = orgUnit.Phone, Fax = orgUnit.Fax, Email = orgUnit.Email, CustomUrl = orgUnit.CustomUrl, CustomLiveUrl = orgUnit.CustomLiveUrl, CustomStageUrl = orgUnit.CustomStageUrl, CustomQaUrl = orgUnit.CustomQaUrl, CustomDevUrl = orgUnit.CustomDevUrl, ServiceLineUrl = orgUnit.ServiceLineUrl, Description = orgUnit.Description, ImageUrl = orgUnit.ImageUrl, PictureId = orgUnit.PictureId.HasValue ? orgUnit.PictureId.Value.ToString(CultureInfo.InvariantCulture) : null, ParentInternalId = orgUnit.ParentId.HasValue ? orgUnit.ParentId.Value.ToString(CultureInfo.InvariantCulture) : null, ParentExternalId = orgUnit.ParentExternalId, CopiedInternalId = orgUnit.LinkedOrgUnitId.HasValue ? orgUnit.LinkedOrgUnitId.Value.ToString(CultureInfo.InvariantCulture) : null, CopiedExternalId = orgUnit.LinkedExternalId, CostCenter = orgUnit.CostCenter, Keywords = orgUnit.Keywords, CustomKeywords = orgUnit.CustomKeywords, Custom1 = orgUnit.Custom1, Custom2 = orgUnit.Custom2, Custom3 = orgUnit.Custom3, DynamicColumns = orgUnit.DynamicColumns, SeoPageTitle = orgUnit.SeoPageTitle, SeoPageDescription = orgUnit.SeoPageDescription, SeoCustomMetaTags = orgUnit.SeoCustomMetaTags, SeoH1Tag = orgUnit.SeoH1Tag, SeoPrimaryKeyword = orgUnit.SeoPrimaryKeyword, SeoSecondaryKeyword = orgUnit.SeoSecondaryKeyword, SeoCanonicalUrl = orgUnit.SeoCanonicalUrl, IsPotentialEventLocation = orgUnit.PotentialEventLocation.ToString(CultureInfo.InvariantCulture) }; //get schedule if (orgUnit.SchedulesOrgUnitId.HasValue) { var scheduleUnitRequest = new ReadOrgUnitRequest(orgUnit.SchedulesOrgUnitId.Value); var scheduleLocation = ProcessRequest<ReadOrgUnitResponse>(scheduleUnitRequest).Location; viewModel.OrgUnitHours = scheduleLocation.Schedules.Select(h => new WeekDayHoursV2 { DayOfWeek = h.Day, OpenTime = h.Open, CloseTime = h.Close }).ToList(); } //get services if (orgUnit.ServicesOrgUnitId.HasValue) { var servicesUnitRequest = new ReadOrgUnitRequest(orgUnit.ServicesOrgUnitId.Value); var servicesLocation = ProcessRequest<ReadOrgUnitResponse>(servicesUnitRequest).Location; viewModel.OrgUnitServices = servicesLocation.Services.Select(s => new OrgUnitServiceV2 { Name = s.ServiceName }).ToList(); } //get insurances if (orgUnit.InsurancesOrgUnitId.HasValue) { var insuranceUnitRequest = new ReadOrgUnitRequest(orgUnit.InsurancesOrgUnitId.Value); var insuranceLocation = ProcessRequest<ReadOrgUnitResponse>(insuranceUnitRequest).Location; viewModel.OrgUnitInsurances = insuranceLocation.Insurances.Select(i => new OrgUnitInsuranceV2 { Name = i.InsuranceName }).ToList(); } //get orgUnitTypes var listLocationOrgUnitTypesRequest = new ListOrgUnitOrgUnitTypesRequest(orgUnit.Id); var queryResponse = ProcessRequest<ListOrgUnitOrgUnitTypesResponse>(listLocationOrgUnitTypesRequest); viewModel.OrgUnitTypes = queryResponse.LocationOrgUnitTypes.Select(t => new OrgUnitTypeV2 { IsPrimaryOrgUnitType = t.IsPrimaryOrgUnitType, Name = t.OrgUnitTypeName }).ToList(); //get discount codes var discountCodeRequest = new ListOrgUnitDiscountCodesRequest(orgUnit.Id); var discountCodeResponse = ProcessRequest<ListOrgUnitDiscountCodesResponse>(discountCodeRequest); viewModel.OrgUnitDiscountCodes = discountCodeResponse.OrgUnitDiscountCodes.Select(d => new OrgUnitDiscountCodeV2 { Code = d.Code, Description = d.Description, DiscountType = d.DiscountTypeName.ToString(CultureInfo.InvariantCulture), DiscountValue = d.DiscountValue.ToString(CultureInfo.InvariantCulture), EndDate = d.EndDate == DateTime.MinValue ? null : d.EndDate.ToString(CultureInfo.InvariantCulture), StartDate = d.StartDate == DateTime.MinValue ? null : d.StartDate.ToString(CultureInfo.InvariantCulture), IsEnabled = d.IsEnabled.ToString(CultureInfo.InvariantCulture), IsGroupCode = d.IsGroupCode.ToString(CultureInfo.InvariantCulture), RequiredGroupSize = d.RequiredGroupSize.ToString(CultureInfo.InvariantCulture) }).ToList(); return CommonUtils.XmlSerialize(viewModel); }