Ejemplo n.º 1
0
        private bool Check(CourseEnrichmentModel model, ICourseEnrichmentViewModel viewModel)
        {
            var result = false;
            var aboutCourseEnrichmentViewModel = viewModel as AboutCourseEnrichmentViewModel;

            if (aboutCourseEnrichmentViewModel != null)
            {
                result = aboutCourseEnrichmentViewModel.AboutCourse == model.AboutCourse &&
                         aboutCourseEnrichmentViewModel.InterviewProcess == model.InterviewProcess &&
                         aboutCourseEnrichmentViewModel.HowSchoolPlacementsWork == model.HowSchoolPlacementsWork;
            }

            var courseRequirementsEnrichmentViewModel = viewModel as CourseRequirementsEnrichmentViewModel;

            if (courseRequirementsEnrichmentViewModel != null)
            {
                result =
                    model.Qualifications == courseRequirementsEnrichmentViewModel.Qualifications &&
                    model.PersonalQualities == courseRequirementsEnrichmentViewModel.PersonalQualities &&
                    model.OtherRequirements == courseRequirementsEnrichmentViewModel.OtherRequirements;
            }

            var courseFeesEnrichmentViewModel = viewModel as CourseFeesEnrichmentViewModel;

            if (courseFeesEnrichmentViewModel != null)
            {
                var courseLength = courseFeesEnrichmentViewModel.CourseLength.HasValue ? courseFeesEnrichmentViewModel.CourseLength.Value.ToString() : null;
                result =
                    model.FeeDetails == courseFeesEnrichmentViewModel.FeeDetails &&
                    model.FeeInternational == courseFeesEnrichmentViewModel.FeeInternational &&
                    model.FeeUkEu == courseFeesEnrichmentViewModel.FeeUkEu &&
                    model.FinancialSupport == courseFeesEnrichmentViewModel.FinancialSupport &&
                    model.CourseLength == courseLength;
            }

            var courseSalaryEnrichmentViewModel = viewModel as CourseSalaryEnrichmentViewModel;

            if (courseSalaryEnrichmentViewModel != null)
            {
                var courseLength = courseSalaryEnrichmentViewModel.CourseLength.HasValue ? courseSalaryEnrichmentViewModel.CourseLength.Value.ToString() : null;
                result =
                    model.SalaryDetails == courseSalaryEnrichmentViewModel.SalaryDetails &&
                    model.CourseLength == courseLength;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private async Task <bool> SaveEnrichment(string providerCode, string courseCode, ICourseEnrichmentViewModel viewModel)
        {
            var course = await _manageApi.GetCourseEnrichment(providerCode, courseCode);

            if (course == null && viewModel.IsEmpty())
            {
                // Draft state is "New" and no changes have been made - don't insert a draft
                return(false);
            }

            var enrichmentModel = course?.EnrichmentModel ?? new CourseEnrichmentModel();

            viewModel.MapInto(ref enrichmentModel);

            await _manageApi.SaveCourseEnrichment(providerCode, courseCode, enrichmentModel);

            return(true);
        }