コード例 #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
ファイル: ActivityProjector.cs プロジェクト: peternunn/Folium
 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 }
         });
     }
 }