public async Task <IHttpActionResult> CreateWall(CreateWallViewModel newWall) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var wallDto = _mapper.Map <CreateWallViewModel, CreateWallDto>(newWall); SetOrganizationAndUser(wallDto); try { var wallId = await _wallService.CreateNewWall(wallDto); var userAndOrg = GetUserAndOrganization(); var notificationDto = await _notificationService.CreateForWall(userAndOrg, wallDto, wallId); NotificationHub.SendNotificationToAllUsers(_mapper.Map <NotificationViewModel>(notificationDto), GetUserAndOrganizationHub()); return(Ok(new { Id = wallId })); } catch (ValidationException e) { return(BadRequestWithError(e)); } }
public async Task Wall_CreateWall_Should_Return_Invalid_Model_State() { var wall = new CreateWallViewModel { Name = "test" }; _wallController.ModelState.AddModelError("model", "error"); var response = await _wallController.CreateWall(wall); Assert.IsInstanceOf <InvalidModelStateResult>(response); }