Exemple #1
0
        public EntryDto UpdateEntry(User user, EntryDto entryDto)
        {
            var entryAggregate = _repository.GetById <EntryAggregate>(entryDto.Id);

            entryAggregate.Update(entryDto.Title, entryDto.DescriptionString(), entryDto.Where, entryDto.When);
            entryAggregate.UpdateAssessmentBundle(
                entryDto.AssessmentBundle.ToDictionary(
                    s => s.Key,
                    s => new SelfAssessment {
                EntryId = entryDto.Id,
                Score   = s.Value.Score,
                SelfAssessmentLevelId = s.Value.LevelId,
                SkillId = s.Key,
                UserId  = user.Id
            }));
            _repository.Save(entryAggregate, commitId: Guid.NewGuid(), updateHeaders: null);
            return(entryDto);
        }
Exemple #2
0
        public EntryDto CreateEntry(User user, EntryDto entryDto)
        {
            var id             = Guid.NewGuid();
            var entryAggregate = (EntryAggregate)_factory.Build(typeof(EntryAggregate), id, null);

            entryAggregate.OnFirstCreated();
            entryAggregate.Create(entryDto.SkillSetId, entryDto.Title, entryDto.DescriptionString(), user.Id, entryDto.Where, entryDto.When, entryDto.EntryType?.Id);
            entryAggregate.AddAssessmentBundle(
                entryDto.AssessmentBundle.ToDictionary(
                    s => s.Key,
                    s => new SelfAssessment {
                EntryId = id,
                Score   = s.Value.Score,
                SelfAssessmentLevelId = s.Value.LevelId,
                SkillId = s.Key,
                UserId  = user.Id
            }));
            _repository.Save(entryAggregate, commitId: Guid.NewGuid(), updateHeaders: null);
            entryDto.Id = id;
            return(entryDto);
        }