public string Add(UserHeader user)
 {
     using (var client = new SecurityTokenServiceClient())
     {
         var token = client.Add(SerializeUser(user));
         client.Close();
         return token;
     }
 }
            public LoginUserHeaderProxy(UserHeader user)
            {
                Id = user.Id;
                Email = user.Email;
                FirstName = user.FirstName;
                LastName = user.LastName;

                Role = Role.None;
            }
 public string AddLogin(UserHeader user)
 {
     using (var client = new SecurityTokenServiceClient())
     {
         var token = client.Add(
             SerializeUser(user).Concat(
                 new[] { new KeyValuePair<string, string>(IsLoginProperty, "true") }).ToArray());
         client.Close();
         return token;
     }
 }
예제 #4
0
        public Cases.Case GetCase(UserHeader user, int id)
        {
            var @case = _database.GetCaseById(id);
            if (@case == null) throw new CaseDoesNotExistsException();
            if (!CanSeeAllCases(user) && !IsUserAssignedToCase(user, @case)) throw new ForbiddenException();
            var state = GetCaseState(@case);
            var partiesComments = _database.GetPartiesComments(id);
            var result = new Cases.Case
            {
                ReadonlyData = new ReadonlyCaseData
                {
                    Id = @case.Id,
                    ParentId = @case.ParentId,
                    State = state,
                },
                InitialData = new InitialCaseData
                {
                    CanBeEdited = state.StateKind == CaseStateKind.New,
                    IsReady = GetIsCaseReadyToStart(@case),
                    StartDate = @case.StartDate,
                    Background = @case.Background,
                    IdealOutcome = @case.IdealOutcome,
                    IssueRaisedWithArchitect = new Question
                    {
                        Answer = @case.IssueRaisedWithArchitect.Answer,
                        Comments = @case.IssueRaisedWithArchitect.Comments,
                    },
                    SubjectOfLegalProceedings = new Question
                    {
                        Answer = @case.SubjectOfLegalProceedings.Answer,
                        Comments = @case.SubjectOfLegalProceedings.Comments,
                    },
                    CasePanelMembers = GetPanelMembers(@case),
                },
                Contacts = new CaseContacts
                {
                    Relationship = @case.Relationship,
                    ContactAgreement = @case.ContactAgreement,
                    ArchitectContact = new ArchitectContact
                    {
                        Name = @case.ArchitectContact.Name,
                        Address = @case.ArchitectContact.Address,
                        EMail = @case.ArchitectContact.EMail,
                        Phone = @case.ArchitectContact.Phone,
                        RegistrationNumber = @case.ArchitectContact.RegistrationNumber,
                    },
                    ClaimantContact = new Contact
                    {
                        Name = @case.ClaimantContact.Name,
                        Address = @case.ClaimantContact.Address,
                        EMail = @case.ClaimantContact.EMail,
                        Phone = @case.ClaimantContact.Phone,
                    },
                },
                DatesAndDetails = @case.DatesAndDetails.Select(item => new DateAndDetail
                {
                    Id = item.Id,
                    Date = item.Date,
                    Text = item.Text,
                    Documents = item.Documents.Select(d => new Document {Id = d.Id, Name = d.Name}).ToArray(),
                }).ToArray(),
                Allegations = new AllegationCollection
                {
                    CanAddAllegation = IsNewOrPreliminaryComments(state),
                    Items = @case.Allegations.Select(item => new Allegation
                    {
                        Id = item.Id,
                        Text = item.Text,
                        MyComment = item.Comments.Where(c => c.PanelMemberId == user.Id).Select(c =>
                            new MyAllegationComment
                            {
                                AllegationCommentType = (AllegationCommentType) c.CommentType,
                                Text = c.Text,
                                AdditionalText = c.AdditionalText,
                            }).FirstOrDefault(),
                        Documents = item.Documents.Select(d => new Document {Id = d.Id, Name = d.Name}).ToArray(),
                        CanBeDeleted = !item.Comments.Any() && IsNewOrPreliminaryComments(state),
                    }).ToArray(),
                },
                PartiesComments = partiesComments,
            };

            result.PreliminaryDecisionDocument = @case.PreliminaryDecisionDocument == null
                ? null
                : new Document {Id = @case.PreliminaryDecisionDocument.Id, Name = @case.PreliminaryDecisionDocument.Name};
            result.FinalDecisionDocument = @case.FinalDecisionDocument == null
                ? null
                : new Document {Id = @case.FinalDecisionDocument.Id, Name = @case.FinalDecisionDocument.Name};

            return result;
        }
예제 #5
0
 public void UpdateUser(UserHeader user)
 {
     using (var transaction = new TransactionScope())
     {
         var userData = _database.GetUserByEmail(user.Email);
         if (userData == null) throw new UserDoesNotExistException();
         userData.FirstName = user.FirstName;
         userData.LastName = user.LastName;
         userData.Role = user.Role;
         _database.UpdateUser(userData);
         transaction.Complete();
     }
 }
예제 #6
0
 public UserHeader CreateUser(UserHeader user)
 {
     using (var transaction = new TransactionScope())
     {
         var userData = _database.GetUserByEmail(user.Email);
         if (userData != null)
         {
             if (userData.UserState != UserState.Deleted) throw new DuplicateUserException();
             userData.UserState = UserState.Created;
             userData.FirstName = user.FirstName;
             userData.LastName = user.LastName;
             userData.HashedPassword = null;
             userData.PasswordSalt = null;
             userData.EncryptedSecurePhrase = null;
             userData.FirstSecurePhraseQuestionCharacterIndex = null;
             userData.SecondSecurePhraseQuestionCharacterIndex = null;
             userData.Role = user.Role;
             _database.UpdateUser(userData);
         }
         else
         {
             userData = new UserData(user);
             if (userData.Id == Guid.Empty) userData.Id = Guid.NewGuid();
             _database.CreateUser(userData);
         }
         var resetToken = new ResetToken
         {
             UserId = userData.Id,
             Token = Guid.NewGuid().ToString(),
             ExpirationTime = DateTime.Now.Add(_configuration.ResetUserTokenLifespan),
             Type = ResetTokenType.Both,
         };
         _database.DeleteExpiredResetTokens();
         _database.DeleteResetTokenIfExists(userData.Id, ResetTokenType.Both);
         _database.AddResetToken(resetToken);
         transaction.Complete();
         _mailNotifier.SendNewUserInstruction(new ResetNotification
         {
             UserId = userData.Id,
             UserEmail = userData.Email,
             UserFirstName = userData.FirstName,
             UserLastName = userData.LastName,
             ResetToken = resetToken.Token,
             ExpirationTime = resetToken.ExpirationTime,
         });
         return userData;
     }
 }
예제 #7
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);
 }
예제 #8
0
 private static void ForbidUnassignedUser(UserHeader user, CaseData @case)
 {
     if (@case.AssignedUsers.All(u => u.Id != user.Id)) throw new ForbiddenException();
 }
예제 #9
0
        public void CommentAllegation(UserHeader user, Guid allegationId, string comment, AllegationCommentType type,
            string additionalComment)
        {
            if (user.Role != Role.PanelMember) throw new ForbiddenException();
            if (string.IsNullOrEmpty(comment)) throw new ArgumentException();
            if (type != AllegationCommentType.Advise && !string.IsNullOrEmpty(additionalComment)) throw new ArgumentException();
            //if (type == AllegationCommentType.Advise && string.IsNullOrEmpty(additionalComment)) throw new ArgumentException();

            var caseId = _database.GetCaseIdByAllegationId(allegationId);
            if (caseId == null) throw new CaseDoesNotExistsException();
            var @case = _database.GetCaseById(caseId.Value);
            var allegation = @case.Allegations.First(a => a.Id == allegationId);

            ForbidUnassignedUser(user, @case);
            ForbidNotPreliminaryCommentsCaseState(@case);
            ForbidSecondComment(user, allegation);

            _database.CreateAllegationComment(allegationId, comment, type, additionalComment, user.Id);

            RejectCaseIfAllAllegationsAreRejected(caseId.Value);
        }
예제 #10
0
 public OverAssignmentException(int caseId, Role role, UserHeader[] alreadyAssigned)
 {
     CaseId = caseId;
     Role = role;
     AlreadyAssigned = alreadyAssigned;
 }
예제 #11
0
 private static bool IsUserAssignedToCase(UserHeader user, CaseData caseData)
 {
     return caseData.AssignedUsers.Any(item => item.Id == user.Id);
 }
예제 #12
0
 private static bool CanSeeAllCases(UserHeader user)
 {
     return user.Role == Role.Admin || user.Role == Role.CaseWorker;
 }
예제 #13
0
 private void AssignCaseWorker(int caseId, UserHeader caseWorker)
 {
     CheckOverassignment(caseId, Role.CaseWorker);
     _database.AssignUser(caseId, caseWorker.Id);
     _mailNotifier.NotifyAssignedCaseWorker(caseId, new User
     {
         UserId = caseWorker.Id,
         Email = caseWorker.Email,
         FirstName = caseWorker.FirstName,
         LastName = caseWorker.LastName,
     });
 }
 private static KeyValuePair<string, string>[] SerializeUser(UserHeader user)
 {
     return new[]
     {
         new KeyValuePair<string, string>(IdProperty, user.Id.ToString()),
         new KeyValuePair<string, string>(EMailProperty, user.Email),
         new KeyValuePair<string, string>(RoleProperty, user.Role.ToString()),
         new KeyValuePair<string, string>(FirstNameProperty, user.FirstName),
         new KeyValuePair<string, string>(LastNameProperty, user.LastName),
     };
 }
예제 #15
0
        public void UpdateCase(UserHeader user, int caseId, CaseUpdate caseUpdate)
        {
            using (var transaction = new TransactionScope())
            {
                var @case = _database.GetCaseById(caseId);
                if (@case.AssignedUsers.All(u => u.Id != user.Id)) throw new ForbiddenException();
                var state = GetCaseState(@case);
                if (caseUpdate.Initial != null && state.StateKind == CaseStateKind.New)
                {
                    @case.StartDate = caseUpdate.Initial.StartDate;
                    @case.Background = caseUpdate.Initial.Background;
                    @case.IdealOutcome = caseUpdate.Initial.IdealOutcome;
                    if (caseUpdate.Initial.IssueRaisedWithArchitect != null)
                    {
                        @case.IssueRaisedWithArchitect = new CaseData.Question
                        {
                            Answer = caseUpdate.Initial.IssueRaisedWithArchitect.Answer,
                            Comments = caseUpdate.Initial.IssueRaisedWithArchitect.Comments,
                        };
                    }
                    if (caseUpdate.Initial.SubjectOfLegalProceedings != null)
                    {
                        @case.SubjectOfLegalProceedings = new CaseData.Question
                        {
                            Answer = caseUpdate.Initial.SubjectOfLegalProceedings.Answer,
                            Comments = caseUpdate.Initial.SubjectOfLegalProceedings.Comments,
                        };
                    }
                }
                if (caseUpdate.Contacts != null)
                {
                    @case.ContactAgreement = caseUpdate.Contacts.ContactAgreement;
                    @case.Relationship = caseUpdate.Contacts.Relationship;
                    if (caseUpdate.Contacts.ArchitectContact != null)
                    {
                        @case.ArchitectContact.Name = caseUpdate.Contacts.ArchitectContact.Name;
                        @case.ArchitectContact.EMail = caseUpdate.Contacts.ArchitectContact.EMail;
                        @case.ArchitectContact.Address = caseUpdate.Contacts.ArchitectContact.Address;
                        @case.ArchitectContact.Phone = caseUpdate.Contacts.ArchitectContact.Phone;
                        @case.ArchitectContact.RegistrationNumber = caseUpdate.Contacts.ArchitectContact.RegistrationNumber;
                    }
                    if (caseUpdate.Contacts.ClaimantContact != null)
                    {
                        @case.ClaimantContact.Name = caseUpdate.Contacts.ClaimantContact.Name;
                        @case.ClaimantContact.EMail = caseUpdate.Contacts.ClaimantContact.EMail;
                        @case.ClaimantContact.Address = caseUpdate.Contacts.ClaimantContact.Address;
                        @case.ClaimantContact.Phone = caseUpdate.Contacts.ClaimantContact.Phone;
                    }
                }

                _database.UpdateCase(@case);

                if (caseUpdate.Initial != null && caseUpdate.Initial.PanelMembers != null)
                    UpdatePanelMembersAssignment(caseId, caseUpdate.Initial.PanelMembers, @case.AssignedUsers);

                if (caseUpdate.DatesAndDetailsUpdate != null)
                {
                    if (caseUpdate.DatesAndDetailsUpdate.NewDatesAndDetails != null)
                    {
                        foreach (var item in caseUpdate.DatesAndDetailsUpdate.NewDatesAndDetails)
                        {
                            int maxDateAndDetailsOrder = _database.GetMaxDateAndDetailOrder(caseId, item.Date);
                            _database.CreateDateAndDetail(caseId, item, user.Id, maxDateAndDetailsOrder + 1);
                            foreach (var document in item.Documents)
                            {
                                _documentStore.Upload(document.Id, caseId,
                                    new DocumentStoreItem {Name = document.Name, Content = document.Body});
                                _database.AddDocumentActivity(new DocumentActivity
                                {
                                    Id = Guid.NewGuid(),
                                    CaseId = @case.Id,
                                    DocumentId = document.Id,
                                    UserId = user.Id,
                                    ActionType = ActionType.Create,
                                    Date = DateTime.Now,
                                    DocumentType = DocumentType.DateAndDetail,
                                    DocumentName = document.Name,
                                });
                            }
                        }
                    }
                    if (caseUpdate.DatesAndDetailsUpdate.DeletedDatesAndDetails != null)
                    {
                        foreach (var item in caseUpdate.DatesAndDetailsUpdate.DeletedDatesAndDetails)
                        {
                            var dateAndDetailDocuments = _database.GetDateAndDetailDocument(item);
                            if (dateAndDetailDocuments != null)
                            {
                                foreach (var document in dateAndDetailDocuments)
                                {
                                    _documentStore.Delete(document.Id);
                                    _database.AddDocumentActivity(new DocumentActivity
                                    {
                                        Id = Guid.NewGuid(),
                                        CaseId = @case.Id,
                                        DocumentId = document.Id,
                                        UserId = user.Id,
                                        ActionType = ActionType.Delete,
                                        Date = DateTime.Now,
                                        DocumentType = DocumentType.DateAndDetail,
                                        DocumentName = document.Name,
                                    });
                                }
                            }
                            _database.DeleteDateAndDetail(item);
                        }
                    }
                }

                if (caseUpdate.AllegationsUpdate != null)
                {
                    if (state.StateKind != CaseStateKind.New && state.StateKind != CaseStateKind.PriliminaryComments)
                    {
                        if (caseUpdate.AllegationsUpdate.DeletedAllegations != null &&
                            caseUpdate.AllegationsUpdate.DeletedAllegations.Length > 0)
                            throw new ForbiddenException();
                        if (caseUpdate.AllegationsUpdate.NewAllegations != null &&
                            caseUpdate.AllegationsUpdate.NewAllegations.Length > 0)
                            throw new ForbiddenException();
                    }
                    if (caseUpdate.AllegationsUpdate.DeletedAllegations != null)
                        foreach (var item in caseUpdate.AllegationsUpdate.DeletedAllegations)
                        {
                            var documents = _database.GetAllegationDocuments(item);
                            foreach (var document in documents)
                            {
                                _documentStore.Delete(document.Id);
                            }
                            _database.DeleteAllegation(item);
                        }
                    if (caseUpdate.AllegationsUpdate.NewAllegations != null)
                    {
                        int order = 0;
                        foreach (var item in caseUpdate.AllegationsUpdate.NewAllegations)
                        {
                            _database.CreateAllegation(caseId, item, user.Id, order++);
                            foreach (var document in item.Documents)
                            {
                                _documentStore.Upload(document.Id, caseId, new DocumentStoreItem
                                {
                                    Name = document.Name,
                                    Content = document.Body,
                                });
                            }
                        }
                    }
                }

                transaction.Complete();
            }
        }
예제 #16
0
 public IEnumerable<CaseHeader> GetCaseHeaders(UserHeader user)
 {
     if (CanSeeAllCases(user))
         return _database.GetAllCaseHeaders();
     return _database.GetCaseHeadersByAssignedUserId(user.Id);
 }
예제 #17
0
        public ComplaintComments GetComments(UserHeader user, int caseId)
        {
            var @case = _database.GetCaseById(caseId);
            var status = GetCaseState(@case);

            var users = GetUsers().Select(x => new Contract.User
            {
                Id = x.Id,
                Email = x.Email,
                FirstName = x.FirstName,
                LastName = x.LastName,
                Role = (Contract.Role) x.Role,
            }).ToArray();

            var allegations = _database.GetAllegationComments(caseId, user.Id);
            var preliminaryDecisionComments = _database.GetPreliminaryDecisionComments(caseId);
            var finalDecisionComments = _database.GetFinalDecisionComments(caseId);

            var finalDecisionApprovedByCurrentUser =
                finalDecisionComments.Any(x => x.PanelMemberId == user.Id && x.Decision == FinalDecisionCommentKind.Accept);

            var allegationsWithOthersComments = allegations
                .Select(x => new ComplaintComments.AllegationWithComments
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Comments = x.Comments.Select(y => new ComplaintComments.AllegationComment
                    {
                        Id = y.Id,
                        Text = y.Text,
                        User = users.FirstOrDefault(u => u.Id == y.PanelMemberId),
                    }).ToArray(),
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                }).ToArray();

            var allegationWithMyComments = allegations.Where(x => x.Allegation.MyComment != null)
                .Select(x => new ComplaintComments.AllegationWithMyComment
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    MyComment = new Contract.Cases.MyAllegationComment
                    {
                        Id = x.Allegation.MyComment.Id,
                        AllegationCommentType =
                            (Contract.Cases.AllegationCommentType) x.Allegation.MyComment.AllegationCommentType,
                        Text = x.Allegation.MyComment.Text,
                        AdditionalText = x.Allegation.MyComment.AdditionalText,
                    },
                    OtherComments = x.Comments
                        .Where(c => c.PanelMemberId != user.Id)
                        .Select(c => new ComplaintComments.AllegationComment
                        {
                            Id = c.Id,
                            Text = c.Text,
                            User = users.FirstOrDefault(u => u.Id == c.PanelMemberId),
                        }).ToArray(),
                });

            var allegationWithNoComments = allegations.Where(x => x.Allegation.MyComment == null)
                .Select(x => new ComplaintComments.AllegationWithMyComment
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    MyComment = new Contract.Cases.MyAllegationComment
                    {
                        Id = Guid.Empty,
                        Text = null,
                        AdditionalText = null,
                        AllegationCommentType = Contract.Cases.AllegationCommentType.No,
                    },
                    OtherComments = x.Comments
                        .Where(c => c.PanelMemberId != user.Id)
                        .Select(c => new ComplaintComments.AllegationComment
                        {
                            Id = c.Id,
                            Text = c.Text,
                            User = users.FirstOrDefault(u => u.Id == c.PanelMemberId),
                        }).ToArray(),
                });
            var partiesComments = _database.GetPartiesComments(caseId);
            var result = new ComplaintComments
            {
                DueDate = status.DueByDate,
                DueDaysLeft = status.DueDaysLeft,
                Status = GetStatus(status),
                FinalDecisionApprovedByCurrentUser = finalDecisionApprovedByCurrentUser,
                PreliminaryComments = new ComplaintComments.PreliminaryCommentsData
                {
                    AllegationsWithComments = allegationsWithOthersComments,
                    AllegationsWithMyComments = allegationWithMyComments.Concat(allegationWithNoComments).ToArray(),
                },
                PreliminaryDecisionComments = new ComplaintComments.PreliminaryDecisionCommentsData
                {
                    Comments = preliminaryDecisionComments.Select(x => new ComplaintComments.AllegationComment
                    {
                        Text = x.Text,
                        User = users.FirstOrDefault(u => u.Id == user.Id),
                    }).ToArray(),
                    CommentsFromParies = partiesComments.Select(x => new ComplaintComments.CommentFromParties
                    {
                        Text = x.Text,
                        Documents = x.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    }).ToArray(),
                    PreliminaryDecisionDocument = @case.PreliminaryDecisionDocument == null
                        ? null
                        : new Contract.Cases.Document
                        {
                            Id = @case.PreliminaryDecisionDocument.Id,
                            Name = @case.PreliminaryDecisionDocument.Name,
                        },
                },
                FinalDecisionDocument = @case.FinalDecisionDocument == null
                    ? null
                    : new Contract.Cases.Document
                    {
                        Id = @case.FinalDecisionDocument.Id,
                        Name = @case.FinalDecisionDocument.Name,
                    },
            };

            return result;
        }
예제 #18
0
 private static void ForbidSecondComment(UserHeader user, CaseData.Allegation allegation)
 {
     if (allegation.Comments.Any(c => c.PanelMemberId == user.Id)) throw new ForbiddenException();
 }
예제 #19
0
 public void AddPartiesComment(UserHeader user, NewPartiesComment newPartiesComment)
 {
     _database.AddPartyComment(newPartiesComment, DateTime.Now);
     foreach (var document in newPartiesComment.Documents)
     {
         _documentStore.Upload(document.Id, newPartiesComment.CaseId, new DocumentStoreItem
         {
             Name = document.Name,
             Content = document.Body,
         });
         _database.AddDocumentActivity(new DocumentActivity
         {
             Id = Guid.NewGuid(),
             CaseId = newPartiesComment.CaseId,
             DocumentId = document.Id,
             DocumentName = document.Name,
             DocumentType = DocumentType.PartyComment,
             ActionType = ActionType.Create,
             UserId = user.Id,
             Date = DateTime.Now
         });
     }
 }
예제 #20
0
 public void StartCaseProcessing(UserHeader user, int caseId)
 {
     var @case = _database.GetCaseById(caseId);
     if (@case.AssignedUsers.All(u => u.Id != user.Id)) throw new ForbiddenException();
     var state = GetCaseState(@case);
     if (state.StateKind != CaseStateKind.New) throw new ForbiddenException();
     @case.Status = CaseData.CaseStatus.Open;
     @case.ProcessStartDate = DateTime.Now;
     _database.UpdateCase(@case);
 }
예제 #21
0
 public void AddFinalDecisionDocument(UserHeader user, int caseId, NewDocument document)
 {
     _database.AddFinalDecisionDocument(caseId, document.Id, document.Name);
     _documentStore.Upload(document.Id, caseId, new DocumentStoreItem {Name = document.Name, Content = document.Body,});
     _database.AddDocumentActivity(new DocumentActivity
     {
         Id = Guid.NewGuid(),
         CaseId = caseId,
         DocumentId = document.Id,
         DocumentName = document.Name,
         DocumentType = DocumentType.FinalDecision,
         ActionType = ActionType.Create,
         UserId = user.Id,
         Date = DateTime.Now
     });
 }
예제 #22
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);
 }
예제 #23
0
 //newly added on sep 4th
 public void UpdatePreliminaryDecisionDocument(UserHeader user, int caseId, NewDocument document)
 {
     var existingDocument = _database.GetPreliminaryDecisionDocument(caseId);
     if (existingDocument == null)
     {
         document.Id = Guid.NewGuid();
         AddPreliminaryDecisionDocument(user, caseId, document);                
     }
     else
     {
         _documentStore.Update(existingDocument.Id, caseId, new DocumentStoreItem {Name = existingDocument.Name, Content = document.Body,});
         _database.AddDocumentActivity(new DocumentActivity
         {
             Id = Guid.NewGuid(),
             CaseId = caseId,
             DocumentId = document.Id,
             DocumentName = document.Name,
             DocumentType = DocumentType.PreliminaryDecision,
             ActionType = ActionType.Update,
             UserId = user.Id,
             Date = DateTime.Now
         });
     }
 }