Пример #1
0
        private Program DoCreate(DraftProgram draftProgram, ProgramServiceValidationEntity validationEntity)
        {
            Contract.Requires(draftProgram != null, "The draft program must not be null.");
            validator.ValidateCreate(validationEntity);
            var program = new Program
            {
                Description     = draftProgram.Description,
                EndDate         = draftProgram.EndDate,
                Name            = draftProgram.Name,
                ParentProgramId = draftProgram.ParentProgramId,
                ProgramType     = null,
                ProgramStatusId = draftProgram.ProgramStatusId,
                StartDate       = draftProgram.StartDate,
                OwnerId         = draftProgram.OwnerOrganizationId
            };

            SetGoals(draftProgram.GoalIds, program);
            SetPointOfContacts(draftProgram.ContactIds, program);
            SetThemes(draftProgram.ThemeIds, program);
            SetRegions(draftProgram.RegionIds, program);
            SetCategories(draftProgram.FocusCategoryIds, program);
            SetObjectives(draftProgram.JustificationObjectiveIds, program);
            SetWebsitesToCreate(draftProgram.Websites, program, draftProgram);

            Debug.Assert(draftProgram.Audit != null, "The audit must not be null.");
            draftProgram.Audit.SetHistory(program);
            this.Context.Programs.Add(program);
            return(program);
        }
Пример #2
0
        private void DoUpdate(Program programToUpdate, EcaProgram updatedProgram, ProgramServiceValidationEntity validationEntity)
        {
            Contract.Requires(updatedProgram != null, "The updated program must not be null.");
            validator.ValidateUpdate(validationEntity);
            programToUpdate.Description     = updatedProgram.Description;
            programToUpdate.EndDate         = updatedProgram.EndDate;
            programToUpdate.Name            = updatedProgram.Name;
            programToUpdate.OwnerId         = updatedProgram.OwnerOrganizationId;
            programToUpdate.ParentProgramId = updatedProgram.ParentProgramId;
            programToUpdate.ProgramStatusId = updatedProgram.ProgramStatusId;
            programToUpdate.RowVersion      = updatedProgram.RowVersion;
            programToUpdate.StartDate       = updatedProgram.StartDate;

            updatedProgram.Audit.SetHistory(programToUpdate);

            SetGoals(updatedProgram.GoalIds, programToUpdate);
            SetPointOfContacts(updatedProgram.ContactIds, programToUpdate);
            SetThemes(updatedProgram.ThemeIds, programToUpdate);
            SetRegions(updatedProgram.RegionIds, programToUpdate);
            SetCategories(updatedProgram.FocusCategoryIds, programToUpdate);
            SetObjectives(updatedProgram.JustificationObjectiveIds, programToUpdate);
            SetWebsitesToUpdate(updatedProgram, programToUpdate);
        }