Esempio n. 1
0
 public void CreatePreliminaryDecisionComment(PreliminaryDecisionComment comment)
 {
     using (var context = new DatabaseContext())
     {
         var entity = context.PreliminaryDecisionComments.Create();
         entity.Id = comment.Id;
         entity.CaseId = comment.CaseId;
         entity.PanelMemberId = comment.PanelMemberId;
         entity.Text = comment.Text;
         entity.Date = comment.Date;
         context.PreliminaryDecisionComments.Add(entity);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 public void AddPreliminaryDecisionComment(UserHeader user, int caseId, 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 PreliminaryDecisionComment
     {
         Id = Guid.NewGuid(),
         CaseId = caseId,
         PanelMemberId = user.Id,
         Text = text,
         Date = DateTime.Now,
     };
     _database.CreatePreliminaryDecisionComment(comment);
     var caseWorker = @case.AssignedUsers.FirstOrDefault(x => x.Role == Role.CaseWorker);
     _mailNotifier.NotifyCaseWorkerAboutPreliminaryDecisionComment(
         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);
 }