public ProviderOrgUnitService(Service service) { if (service == null) { throw new ArgumentNullException("service"); } Service = service; }
public void map_Service_to_ServiceDto() { var service = new Service { Id = 1, Description = "test desc", Name = "test", IsEnabled = true }; var dto = Mapper.Map<Service, ServiceDto>(service); Assert.AreEqual(service.Id, dto.Id); }
/// <summary> /// Removes the service. /// </summary> /// <param name="service">The service.</param> /// <returns>A ProviderOrgUnitService instance if a custom service was removed.</returns> public ProviderOrgUnitService RemoveService(Service service) { if (service == null) { throw new ArgumentNullException("service"); } var providerOrgUnitService = ProviderOrgUnitServices.SingleOrDefault(pli => pli.Service.Id == service.Id); if (providerOrgUnitService != null) { ProviderOrgUnitServices.Remove(providerOrgUnitService); return providerOrgUnitService; } return null; }
/// <summary> /// Adds the service. /// </summary> /// <param name="service">The service.</param> public void AddService(Service service) { if (service == null) { throw new ArgumentNullException("service"); } ProviderOrgUnitServices.Add(new ProviderOrgUnitService(service)); }
private static ICollection<ProviderOrgUnitService> SetServices(ObjectContext context, ProviderOrgUnitV2 source, Provider provider, ICollection<ProviderOrgUnitService> existingServices) { if (source.Services == null) return existingServices; try { //Delete existing services to be sure they are not duplicated. existingServices.ToList().ForEach(s => context.DeleteObject(s)); var Services = context.CreateObjectSet<Service>(); var providerOrgUnitServices = new List<ProviderOrgUnitService>(); foreach (ProviderOrgUnitServiceV2 item in source.Services) { if (string.IsNullOrEmpty(item.Name)) continue; //Ensure Service Exists var service = Services.FirstOrDefault(s => s.Name == item.Name); if (service == null) { service = new Service { Name = item.Name, IsEnabled = true }; Services.AddObject(service); } providerOrgUnitServices.Add(new ProviderOrgUnitService(service)); } return providerOrgUnitServices; } catch (Exception ex) { throw new BusinessException("Error processing services for provider '" + provider.Name + "' - " + ex.Message, ex); } }
public static void SetProviderOrgUnitAffiliations(ObjectContext context, ProviderV2 source, Provider provider) { if (source.OrgUnitAffiliations == null) return; try { var existingOrgUntiAffiliation = provider.ProviderOrgUnitAffiliations.ToArray(); foreach (var item in existingOrgUntiAffiliation) context.DeleteObject(item); var providerOrgUnitAffiliations = new List<ProviderOrgUnitAffiliation>(); var services = context.CreateObjectSet<Service>(); foreach (var item in source.OrgUnitAffiliations) { var orgUnitId = ConvertToInt(item.OrgUnitId, "HospitalAffiliation/OrgUnitId", provider.FullName); var orgUnitTypeId = ConvertToInt(item.OrgUnitTypeId, "HospitalAffiliation/OrgUnitId", provider.FullName); var orgUnit = context.CreateObjectSet<OrgUnit>().SingleOrDefault(o => o.Id == orgUnitId && o.OrgUnitTypeAssociations.Any(t => t.OrgUnitType.Id == orgUnitTypeId)); if (orgUnit == null) throw new BusinessException("No org unit exists for org unit id '" + item.OrgUnitId + "' and org unit type id '" + item.OrgUnitTypeId + "'"); var service = services.SingleOrDefault(s => s.Name == item.Service); if (service == null) { service = new Service { Name = item.Service, Description = item.Service, IsEnabled = true }; services.AddObject(service); } providerOrgUnitAffiliations.Add(new ProviderOrgUnitAffiliation { OrgUnitId = orgUnitId, OrgUnitTypeId = orgUnitTypeId, Service = service }); } provider.ProviderOrgUnitAffiliations = providerOrgUnitAffiliations; } catch (Exception ex) { throw new BusinessException("Error processing clinical interests for provider '" + provider.Name + "' - " + ex.Message, ex); } }
private void FixupService(Service previousValue) { if (Service != null) { if (ServiceId != Service.Id) { ServiceId = Service.Id; } } }
private static void BuildKeywordsWithInternalSynonymGenerator(Service service, ISettingsManager settingsManager) { var newKeywords = BuildKeywordsWithSynonyms(settingsManager, service.Keywords, _excludedWords); service.Keywords = newKeywords; }
public static void SetOrgUnitServices(ObjectContext context, OrgUnitV2 source, OrgUnit orgUnit) { //ignore null values if (source.OrgUnitServices == null) return; try { var existingServices = orgUnit.OrgUnitServices.ToArray(); foreach (var item in existingServices) context.DeleteObject(item); var services = context.CreateObjectSet<Service>(); var orgUnitServices = new List<OrgUnitService>(); foreach (var item in source.OrgUnitServices) { //Ensure service Exists var service = services.FirstOrDefault(i => i.Name == item.Name); if (service == null) { service = new Service() { Name = item.Name, IsEnabled = true }; services.AddObject(service); } orgUnitServices.Add(new OrgUnitService { Service = service, OrgUnit = orgUnit }); } orgUnit.OrgUnitServices = orgUnitServices; } catch (Exception ex) { throw new BusinessException("Error processing services for orgUnit '" + orgUnit.Name + "' - " + ex.Message, ex); } }