Esempio n. 1
0
        public void Decline(string selfUserName, int documentId)
        {
            DocumentEntity documentEntity = _documentRepository
                                            .Get(e => e.Id == documentId)
                                            .FirstOrDefault(e => e.Reviewers.Any(u => u.UserName == selfUserName));

            if (documentEntity == null)
            {
                throw new DocManagerException("Requested document does not exist or not accessible.");
            }

            DocumentEntity document = _documentRepository
                                      .Get(e => e.Id == documentId)
                                      .FirstOrDefault();

            if (document?.Status.Name != "Need review")
            {
                throw new DocManagerException("You cannot modify document in approved status.");
            }

            StatusEntity statusEntity = _statusRepository
                                        .GetAll()
                                        .AsNoTracking()
                                        .FirstOrDefault(s => s.Name == "Approved");

            document.Status = statusEntity;

            DocumentVersionEntity last = document.DocumentVersions.Last();

            document.DocumentVersions = document.DocumentVersions
                                        .Except(new []
            {
                last
            })
                                        .ToList();

            _documentVersionRepository.Delete(last);

            _documentRepository.CommitAsync();
        }
Esempio n. 2
0
 public void DeleteDocumentVersion(DocumentVersion documentVersion)
 {
     _documentVersionRepository.Delete(Mapper.Map <DocumentVersionEntity>(documentVersion));
 }