Esempio n. 1
0
        public void maps_education()
        {
            var provider = new Provider
            {
                Id = 123
            };

            var educationType = new EducationType(Guid.NewGuid().ToString(), true);
            //var educationType = new EducationType();
            educationType.Id = 567;
            var providerEducation = new ProviderEducation(provider, educationType, Guid.NewGuid().ToString());
            providerEducation.SetYearCompleted(null);

            var education = Mapper.Map<ProviderEducation, ProviderEducationDto>(providerEducation);

            Assert.IsNotNull(education);
            Assert.AreEqual(providerEducation.Id, education.Id);
            Assert.AreEqual(providerEducation.EducationType.Name, education.EducationTypeName);
            Assert.AreEqual(providerEducation.InstitutionName, education.InstitutionName);
            Assert.AreEqual(providerEducation.IsCompleted, education.IsCompleted);
            Assert.AreEqual(providerEducation.YearCompleted, education.YearCompleted);
        }
        public void throws_exception_when_no_provider_specified()
        {
            //setup
            Provider provider = null;
            var educationType = CreateEducationType();

            //act
            var providerEducation = new ProviderEducation(provider, educationType, _validInstitutionName);
        }
        public void throws_exception_when_no_educationType_specified()
        {
            //setup
            var provider = CreateProvider();
            EducationType educationType = null;

            //act
            var providerEducation = new ProviderEducation(provider, educationType, _validInstitutionName);
        }
        public void throws_business_exception_when_tooLong_institutionName_specified()
        {
            //setup
            var provider = CreateProvider();
            var educationType = CreateEducationType();

            //act
            var providerEducation = new ProviderEducation(provider, educationType, _tooLongInstitutionName);
        }
        public void throws_business_exception_when_no_institutionName_specified()
        {
            //setup
            var provider = CreateProvider();
            var educationType = CreateEducationType();
            string institutionName = null;

            //act
            var providerEducation = new ProviderEducation(provider, educationType, institutionName);
        }
Esempio n. 6
0
 /// <summary>
 /// Adds the provider education.
 /// </summary>
 /// <param name="providerEducation">The provider education.</param>
 public void AddProviderEducation(ProviderEducation providerEducation)
 {
     if (providerEducation == null)
     {
         throw new ArgumentNullException("providerEducation");
     }
     ProviderEducations.Add(providerEducation);
 }
Esempio n. 7
0
        public static void SetProviderEducationTypes(ObjectContext context, ProviderV2 source, Provider provider)
        {
            if (source.EducationTypes == null)
                return;

            try
            {
                var existingEducationTypes = provider.ProviderEducations.ToArray();
                foreach (var item in existingEducationTypes)
                    context.DeleteObject(item);

                var educationTypes = context.CreateObjectSet<EducationType>();
                var providerEducations = new List<ProviderEducation>();

                foreach (var item in source.EducationTypes)
                {
                    //Ensure Education Type Exists
                    var education = educationTypes.FirstOrDefault(s => s.Name == item.EducationTypeName);
                    if (education == null)
                    {
                        education = new EducationType(item.EducationTypeName, true);
                        educationTypes.AddObject(education);
                    }

                    var addedEducation = new ProviderEducation(provider, education, item.InstitutionName);
                    addedEducation.SetYearCompleted(item.YearCompleted);

                    if (ConvertToBool(item.IsComplete, false, "Education/IsCompleted", provider.Name) || !string.IsNullOrEmpty(item.YearCompleted))
                        addedEducation.IsCompleted = true;

                    providerEducations.Add(addedEducation);
                }

                provider.ProviderEducations = providerEducations;
            }
            catch (Exception ex)
            {
                throw new BusinessException("Error processing educations for provider '" + provider.Name + "' - " + ex.Message, ex);
            }
        }