public ShortBoard(ShortBoardDTO dto) { Name = dto.Name; BoardId = dto.BoardId; IsRead = dto.IsRead; ExchangeName = dto.ExchangeName; }
private async void OnNewBoardClick() { if (ActiveUser.IsActive == true) { ShortBoardDTO dto = await BoardService.CreateBoard(ActiveUser.Instance.LoggedUser.Token, new CreateBoardDTO("Unnamed Board")); if (dto == null) { ShowMessageBox(null, "Creation unsuccessful."); } else { Boards.Add(new ShortBoard(dto)); } } }
//Ako ne uspe dodavanje board-a vratice se null public ShortBoardDTO InsertBoard(CreateBoardDTO boardDTO, string username) { Board board = boardDTO.FromDTO(); board.ExchangeName = Guid.NewGuid().ToString(); ShortBoardDTO dto = null; using (UnitOfWork unit = new UnitOfWork()) { User creator = unit.UserRepository.GetUserByUsername(username); if (board != null && creator != null) { Permission permision = new Permission() { IsAdmin = true, Board = board, User = creator }; BoardNotification boardNotif = new BoardNotification() { Board = board, User = creator }; unit.PermissionRepository.Insert(permision); unit.BoardNotificationRepository.Insert(boardNotif); if (unit.Save()) { dto = new ShortBoardDTO(board, true); RabbitMQService.DeclareExchange(board.ExchangeName); } } } return(dto); }