private async Task JoinOrLeaveEventWallAsync(string responsibleUserId, string wallParticipantId, int wallId, UserAndOrganizationDto userOrg) { if (responsibleUserId != wallParticipantId) { await _wallService.JoinOrLeaveWallAsync(wallId, wallParticipantId, wallParticipantId, userOrg.OrganizationId, true); } }
public async Task <IHttpActionResult> JoinWall(int wallId, string attendeeId = null) { if (wallId <= 0) { return(BadRequest()); } var userAndOrg = GetUserAndOrganization(); if (string.IsNullOrEmpty(attendeeId)) { attendeeId = userAndOrg.UserId; } try { var userDto = await _wallService.JoinOrLeaveWallAsync(wallId, attendeeId, userAndOrg.UserId, userAndOrg.OrganizationId, false); var result = _mapper.Map <ApplicationUserMinimalDto, ApplicationUserMinimalViewModel>(userDto); return(Ok(result)); } catch (ValidationException e) { return(BadRequestWithError(e)); } catch (UnauthorizedException) { return(Forbidden()); } }
public async Task Wall_JoinWall_Should_Return_View_Model() { const int wallId = 1; var userDto = new ApplicationUserMinimalDto { Id = "Id" }; _wallService.JoinOrLeaveWallAsync(wallId, null, null, 0, false).ReturnsForAnyArgs(userDto); var response = await _wallController.JoinWall(wallId); Assert.IsInstanceOf <OkNegotiatedContentResult <ApplicationUserMinimalViewModel> >(response); }
private async Task UpdateWallAsync(Event currentEvent, EditEventDto updatedEvent) { var updateWallDto = new UpdateWallDto { Id = currentEvent.WallId, Description = updatedEvent.Description, Logo = updatedEvent.ImageName, Name = updatedEvent.Name, OrganizationId = updatedEvent.OrganizationId, UserId = updatedEvent.UserId }; await _wallService.UpdateWallAsync(updateWallDto); var responsibleUserChanged = currentEvent.ResponsibleUserId != updatedEvent.ResponsibleUserId; var currentHostIsParticipating = currentEvent.EventParticipants.Any(x => x.ApplicationUserId == currentEvent.ResponsibleUserId); var newHostIsParticipating = currentEvent.EventParticipants.Any(p => p.ApplicationUserId == updatedEvent.ResponsibleUserId); if (!responsibleUserChanged) { return; } await _wallService.RemoveModeratorAsync(currentEvent.WallId, currentEvent.ResponsibleUserId, updatedEvent); await _wallService.AddModeratorAsync(currentEvent.WallId, updatedEvent.ResponsibleUserId, updatedEvent); if (!newHostIsParticipating) { await _wallService.JoinOrLeaveWallAsync(currentEvent.WallId, updatedEvent.ResponsibleUserId, updatedEvent.ResponsibleUserId, updatedEvent.OrganizationId, true); } if (!currentHostIsParticipating) { await _wallService.JoinOrLeaveWallAsync(currentEvent.WallId, currentEvent.ResponsibleUserId, currentEvent.ResponsibleUserId, updatedEvent.OrganizationId, true); } }