/// <summary>
 /// Sets the type of the education.
 /// </summary>
 /// <param name="educationType">Type of the education.</param>
 public virtual void SetEducationType(EducationType educationType)
 {
     if (educationType == null)
     {
         throw new ArgumentNullException("educationType");
     }
     EducationType = educationType;
 }
 public ProviderEducation(Provider provider, EducationType educationType, string institutionName)
     : this()
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     Provider = provider;
     SetEducationType(educationType);
     SetInstitutionName(institutionName);
 }
        public void can_set_educationType()
        {
            //setup
            var providerEducation = CreateValidProviderEducation();
            var educationType = new EducationType("test", true);
            educationType.Id = 99;

            //act
            providerEducation.SetEducationType(educationType);

            //assert
            Assert.AreSame(educationType, providerEducation.EducationType);
        }
Esempio n. 4
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);
        }
 private EducationType CreateEducationType()
 {
     var educationType = new EducationType("name", true);
     educationType.Id = _educationTypeId;
     return educationType;
 }
Esempio n. 6
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);
            }
        }