public async Task <IHttpActionResult> EditWall(UpdateWallViewModel updateWallViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var updateWallDto = _mapper.Map <UpdateWallViewModel, UpdateWallDto>(updateWallViewModel); SetOrganizationAndUser(updateWallDto); try { await _wallService.UpdateWallAsync(updateWallDto); return(Ok()); } catch (ValidationException e) { return(BadRequestWithError(e)); } catch (UnauthorizedException) { return(Unauthorized()); } }
private async Task UpdateWallAsync(EditProjectDto dto, int wallId) { var updateWallDto = new UpdateWallDto { Id = wallId, Description = dto.Description, Logo = dto.Logo, Name = dto.Title, OrganizationId = dto.OrganizationId, UserId = dto.UserId }; await _wallService.UpdateWallAsync(updateWallDto); }
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); } }