public void TestGetAllUserEdits()
        {
            _userEditRepo.Create(RandomUserEdit());
            _userEditRepo.Create(RandomUserEdit());
            _userEditRepo.Create(RandomUserEdit());

            var getResult = _userEditController.Get(_projId).Result;

            Assert.IsInstanceOf <ObjectResult>(getResult);

            var edits = (getResult as ObjectResult).Value as List <UserEdit>;

            Assert.That(edits, Has.Count.EqualTo(3));
            _userEditRepo.GetAllUserEdits(_projId).Result.ForEach(edit => Assert.Contains(edit, edits));
        }
Exemple #2
0
        public async Task <IActionResult> Get(string projectId)
        {
            if (!_permissionService.HasProjectPermission(Permission.WordEntry, HttpContext))
            {
                return(new ForbidResult());
            }

            // Ensure project exists
            var proj = _projectService.GetProject(projectId);

            if (proj == null)
            {
                return(new NotFoundObjectResult(projectId));
            }

            return(new ObjectResult(await _repo.GetAllUserEdits(projectId)));
        }
        public async Task <IActionResult> GetProjectUserEdits(string projectId)
        {
            if (!await _permissionService.HasProjectPermission(HttpContext, Permission.WordEntry))
            {
                return(Forbid());
            }

            // Ensure project exists
            var proj = await _projRepo.GetProject(projectId);

            if (proj is null)
            {
                return(NotFound(projectId));
            }

            return(Ok(await _userEditRepo.GetAllUserEdits(projectId)));
        }