示例#1
0
        public async Task <Unit> Handle(InitReviewerCommand request, CancellationToken cancellationToken)
        {
            var user       = _identitySvc.GetUser();
            var userFromDb = await _reviewerRepo.Find(user.Id);

            if (userFromDb == null)
            {
                userFromDb = new ReviewerInfo
                {
                    Id                = user.Id,
                    EmpId             = user.EmployeeId,
                    FirstName         = user.FirstName,
                    LastName          = user.LastName,
                    LastLoginDateTime = user.LoginTime,
                    LoginName         = user.UserName
                };
                _reviewerRepo.Add(userFromDb);
            }
            else
            {
                userFromDb.Id                = user.Id;
                userFromDb.EmpId             = user.EmployeeId;
                userFromDb.FirstName         = user.FirstName;
                userFromDb.LastName          = user.LastName;
                userFromDb.LastLoginDateTime = user.LoginTime;
                userFromDb.LoginName         = user.UserName;
            }
            await _uow.SaveEntitiesAsync();

            return(Unit.Value);
        }
示例#2
0
        // GET: Review/Edit/5
        public ActionResult Edit(int id)
        {
            ReviewerInfo reviewerInfo = _reviewService.GetReviewById(id);

            if (reviewerInfo == null)
            {
                _loggingService.Log("Can't edit a review that doesn't exist in the database");
                return(HttpNotFound());
            }
            return(View(_mapper.Map <ReviewViewModel>(reviewerInfo)));
        }
示例#3
0
        public void TestReviewUpdate()
        {
            var reviewRepo  = new Mock <IReviewerRepository>();
            var service     = new ReviewerService(reviewRepo.Object);
            var dummyReview = new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today);

            reviewRepo.Setup(i => i.UpdateReview(new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today))).Returns(true);
            var expected = true;
            var actual   = service.UpdateReview(dummyReview);

            Assert.AreEqual(expected, actual, "Update failed");
        }
示例#4
0
        public void TestReviewAdd()
        {
            var reviewRepo  = new Mock <IReviewerRepository>();
            var service     = new ReviewerService(reviewRepo.Object);
            var dummyReview = new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today);

            reviewRepo.Setup(i => i.AddReview(new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today))).Returns(true);
            var expected = true;
            var actual   = service.AddReview(dummyReview);

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(expected, actual, "Delete failed");
        }
示例#5
0
        // GET: Review/Details/5
        public ActionResult Details(int id)
        {
            ReviewerInfo reviewerInfo = _reviewService.GetReviewById(id);

            if (reviewerInfo == null)
            {
                _loggingService.Log("Cant get the details of a review that doesn't exist");
                return(HttpNotFound());
            }
            var review = _mapper.Map <ReviewViewModel>(reviewerInfo);

            return(View(review));
        }
示例#6
0
        public void TestReviewRead()
        {
            var reviewRepo  = new Mock <IReviewerRepository>();
            var service     = new ReviewerService(reviewRepo.Object);
            var dummyReview = new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today);

            reviewRepo.Setup(i => i.GetReviewById(34)).Returns(new ReviewerInfo(34, 22, "Oh hi mark", 7, DateTime.Today));
            var expected = dummyReview;

            var actual = service.GetReviewById(34);

            Assert.AreEqual(expected, actual, "Delete failed");
        }
        public bool DeleteReview(ReviewerInfo reviewer)
        {
            try
            {
                _context.ReviewerInfoes.Remove(reviewer);
                _context.SaveChanges();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public bool AddReview(ReviewerInfo reviewer)
        {
            try
            {
                _context.ReviewerInfoes.Add(reviewer);
                _context.SaveChanges();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public bool UpdateReview(ReviewerInfo reviewer)
        {
            try
            {
                var review = _context.ReviewerInfoes.Find(reviewer.reviewerId);
                if (review != null)
                {
                    _context.Entry(review).CurrentValues.SetValues(reviewer);
                    _context.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
示例#10
0
 public bool UpdateReview(ReviewerInfo review)
 {
     return(_reviewRepository.UpdateReview(review));
 }
示例#11
0
 public bool DeleteReview(ReviewerInfo review)
 {
     return(_reviewRepository.DeleteReview(review));
 }
示例#12
0
 public bool AddReview(ReviewerInfo review)
 {
     return(_reviewRepository.AddReview(review));
 }
示例#13
0
 public void Add(ReviewerInfo reviewer)
 {
     _context.ReviewerInfo.Add(reviewer);
 }
        /// <summary>
        /// Deletes document collaborator
        /// </summary>
        public static void DeleteCollaborator()
        {
            try
            {
                //ExStart:DeleteCollaborator
                // Create instance of annotator.
                AnnotationConfig cfg = CommonUtilities.GetConfiguration();

                //Create annotation handler
                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

                IUserDataHandler userRepository = annotator.GetUserDataHandler();

                IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
                if (!Directory.Exists(cfg.StoragePath))
                {
                    Directory.CreateDirectory(cfg.StoragePath);
                }

                // Create a user that will be an owner.
                // Get user from the storage
                var owner = userRepository.GetUserByEmail("*****@*****.**");

                // If user doesn’t exist in the storage then create it.
                if (owner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    owner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Get document data object in the storage
                var document = documentRepository.GetDocument("Document.pdf");

                // If document already created or it hasn’t owner then delete document
                if (document != null && document.OwnerId != owner.Id)
                {
                    documentRepository.Remove(document);
                    document = null;
                }

                // Get document id if document already created or create new document
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, owner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**", //user email, unique identifier
                    FirstName    = "Judy",
                    LastName     = "Doe",
                    AccessRights = AnnotationReviewerRights.All
                };

                // Delete collaborator
                var deleteCollaboratorResult = annotator.DeleteCollaborator(documentId, reviewerInfo.PrimaryEmail);
                //ExEnd:DeleteCollaborator
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#15
0
        /// <summary>
        /// Deletes document collaborator
        /// </summary>
        public static void DeleteCollaborator()
        {
            try
            {
                //ExStart:DeleteCollaborator
                // Create repository path finder
                IRepositoryPathFinder pathFinder = new RepositoryPathFinder();
                var userRepository = new UserRepository(pathFinder);

                var documentRepository = new DocumentRepository(pathFinder);

                // Create instance of annotator
                IAnnotator annotator = new Annotator(
                    userRepository,
                    documentRepository,
                    new AnnotationRepository(pathFinder),
                    new AnnotationReplyRepository(pathFinder),
                    new AnnotationCollaboratorRepository(pathFinder));

                // Create a user that will be an owner.
                // Get user from the storage
                var owner = userRepository.GetUserByEmail("*****@*****.**");

                // If user doesn’t exist in the storage then create it.
                if (owner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    owner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Get document data object in the storage
                var document = documentRepository.GetDocument("Document.pdf");

                // If document already created or it hasn’t owner then delete document
                if (document != null && document.OwnerId != owner.Id)
                {
                    documentRepository.Remove(document);
                    document = null;
                }

                // Get document id if document already created or create new document
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, owner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**", //user email, unique identifier
                    FirstName    = "Judy",
                    LastName     = "Doe",
                    AccessRights = AnnotationReviewerRights.All
                };

                // Delete collaborator
                var deleteCollaboratorResult = annotator.DeleteCollaborator(documentId, reviewerInfo.PrimaryEmail);
                //ExEnd:DeleteCollaborator
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#16
0
        /// <summary>
        /// Manages collaborator rights
        /// </summary>
        public static void ManageCollaboratorRights()
        {
            try
            {
                //ExStart:ManageCollaboratorRights
                IRepositoryPathFinder pathFinder = new RepositoryPathFinder();

                var userRepository     = new UserRepository(pathFinder);
                var documentRepository = new DocumentRepository(pathFinder);

                // Create instance of annotator
                IAnnotator annotator = new Annotator(
                    userRepository,
                    documentRepository,
                    new AnnotationRepository(pathFinder),
                    new AnnotationReplyRepository(pathFinder),
                    new AnnotationCollaboratorRepository(pathFinder));

                // Create owner.
                var johnOwner = userRepository.GetUserByEmail("*****@*****.**");
                if (johnOwner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    johnOwner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Create document data object in storage
                var  document   = documentRepository.GetDocument("Document.pdf");
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, johnOwner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**",
                    FirstName    = "Judy",
                    LastName     = "Doe",

                    // Can only get view annotations
                    AccessRights = AnnotationReviewerRights.CanView
                };

                // Add collaboorator to the document. If user with Email equals to reviewers PrimaryEmail is absent it will be created.
                var addCollaboratorResult = annotator.AddCollaborator(documentId, reviewerInfo);

                // Get document collaborators
                var getCollaboratorsResult = annotator.GetCollaborators(documentId);
                var judy = userRepository.GetUserByEmail("*****@*****.**");

                // Create annotation object
                AnnotationInfo pointAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 81.0),
                    Box         = new Rectangle(212f, 81f, 142f, 0.0f),
                    Type        = AnnotationType.Point,
                    PageNumber  = 0,
                    CreatorName = "Anonym A."
                };

                // John try to add annotations. User is owner of the document.
                var johnResult = annotator.CreateAnnotation(pointAnnotation, documentId, johnOwner.Id);

                // Judy try to add annotations
                try
                {
                    var judyResult = annotator.CreateAnnotation(pointAnnotation, documentId, judy.Id);
                }

                //Get exceptions, because user can only view annotations
                catch (AnnotatorException e)
                {
                    Console.Write(e.Message);
                    Console.ReadKey();
                }

                // Allow Judy create annotations.
                reviewerInfo.AccessRights = AnnotationReviewerRights.CanAnnotate;
                var updateCollaboratorResult = annotator.UpdateCollaborator(documentId, reviewerInfo);

                // Now user can add annotations
                var judyResultCanAnnotate = annotator.CreateAnnotation(pointAnnotation, documentId, judy.Id);
                //ExEnd:ManageCollaboratorRights
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#17
0
 public void Output(ReviewerInfo review)
 {
     Console.WriteLine(review);
 }