예제 #1
0
        private void CreateSelfAssessment(IDbTransaction tx, ICommit commit, SkillSelfAssessmentCreated @event)
        {
            // A self assessment has been added. We need to insert it.
            var sqlParameters =
                new {
                @event.SelfAssessment.UserId,
                @event.SelfAssessment.SkillId,
                @event.SkillSetId,
                @event.SelfAssessment.SelfAssessmentLevelId,
                @event.SelfAssessment.Score,
                @event.SelfAssessment.CreatedAt
            };

            const string sql = @"
				INSERT INTO [dbo].[SelfAssessmentProjector.SelfAssessment]
					([UserId]
					,[SkillId]
					,[SkillSetId]
					,[SelfAssessmentLevelId]
					,[Score]
					,[CreatedAt])
				SELECT  
					@UserId
					,@SkillId
					,@SkillSetId
					,@SelfAssessmentLevelId
					,@Score
					,@CreatedAt
				WHERE NOT EXISTS(SELECT * FROM [dbo].[SelfAssessmentProjector.SelfAssessment] WHERE [UserId] = @UserId AND [SkillId] = @SkillId);"                ;

            tx.Connection.Execute(sql, (object)sqlParameters, tx);
        }
예제 #2
0
 private void OnSelfAssessmentCreated(IDbTransaction tx, ICommit commit, SkillSelfAssessmentCreated @event)
 {
     RecordActivity(tx, new Models.Activity {
         UserId = @event.SelfAssessment.UserId,
         Type   = (int)ActivityType.SelfAssessmentCreated,
         When   = @event.SelfAssessment.CreatedAt,
         Link   = @event.SelfAssessment.SkillId.ToString()
     });
 }
예제 #3
0
 void Apply(SkillSelfAssessmentCreated @event)
 {
     if (!_selfAssessments.ContainsKey(@event.SelfAssessment.SkillId))
     {
         _selfAssessments.Add(@event.SelfAssessment.SkillId, new SortedList <double, SelfAssessment> {
             { @event.SelfAssessment.CreatedAt.ToUnixTimeMilliseconds(), @event.SelfAssessment }
         });
     }
 }