Esempio n. 1
0
        public async Task <IHttpActionResult> GetWall(int wallId)
        {
            if (wallId <= 0)
            {
                return(BadRequest());
            }

            try
            {
                var userAndOrg = GetUserAndOrganization();

                var wall = await _wallService.GetWallDetailsAsync(wallId, userAndOrg);

                if (!await _permissionService.UserHasPermissionAsync(userAndOrg, BasicPermissions.Post) && wall.Type != WallType.Events)
                {
                    return(Forbidden());
                }

                var mappedWall = _mapper.Map <WallDto, WallListViewModel>(wall);
                return(Ok(mappedWall));
            }
            catch (ValidationException e)
            {
                return(BadRequestWithError(e));
            }
        }
        public async Task Wall_GetWall_Should_Return_View_Model()
        {
            var wallId = 1;
            var wall   = new WallDto
            {
                Id = wallId
            };

            _wallService.GetWallAsync(wallId, null).Returns(new WallDto {
                Type = WallType.UserCreated
            });
            _wallService.GetWallDetailsAsync(0, null).ReturnsForAnyArgs(Task.Run(() => wall));

            var response = await _wallController.GetWall(wallId);

            Assert.IsInstanceOf <OkNegotiatedContentResult <WallListViewModel> >(response);
        }