Exemplo 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);
        }
Exemplo n.º 2
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);
            }
        }