Esempio n. 1
0
 public void CreateFinalDecisionComment(FinalDecisionComment comment)
 {
     using (var context = new DatabaseContext())
     {
         var entity = context.FinalDecisionComments.Create();
         entity.Id = comment.Id;
         entity.CaseId = comment.CaseId;
         entity.PanelMemberId = comment.PanelMemberId;
         entity.Decision = comment.Decision;
         entity.CommentForChange = comment.CommentForChange;
         entity.Date = comment.Date;
         context.FinalDecisionComments.Add(entity);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 public void AddFinalDecisionComment(UserHeader user, int caseId, FinalDecisionCommentKind decision, string text)
 {
     var @case = _database.GetCaseById(caseId);
     if (user.Role != Role.PanelMember) throw new ForbiddenException();
     if (@case.AssignedUsers.All(x => x.Id != user.Id)) throw new ForbiddenException();
     var comment = new FinalDecisionComment
     {
         Id = Guid.NewGuid(),
         CaseId = caseId,
         PanelMemberId = user.Id,
         Decision = decision,
         CommentForChange = text,
         Date = DateTime.Now,
     };
     _database.CreateFinalDecisionComment(comment);
     var caseWorker = @case.AssignedUsers.FirstOrDefault(x => x.Role == Role.CaseWorker);
     _mailNotifier.NotifyCaseWorkerAboutFinalDecisionComment(
         new User
         {
             UserId = caseWorker.Id,
             Email = caseWorker.Email,
             FirstName = caseWorker.FirstName,
             LastName = caseWorker.LastName
         },
         new User {UserId = user.Id, Email = user.Email, FirstName = user.FirstName, LastName = user.LastName},
         caseId, text == null ? decision.ToString() : decision + ": " + text);
 }