// AddTagTo <albumName> <tag> public string Execute(string[] args) { var albumName = args[0]; var tag = args[1]; if (!userSessionService.IsLoggedIn()) { throw new InvalidOperationException("Invalid credentials!"); } var username = userSessionService.User.Username; AlbumRoleDto roleDto = albumRoleService.GetAlbumOwner <AlbumRoleDto>(albumName, username); if (roleDto == null) { throw new InvalidOperationException("Invalid credentials!"); } if (tagService.Exists(tag) == false && albumService.Exists(albumName)) { throw new ArgumentException("Either tag or album do not exist!"); } var tagDto = tagService.ByName <TagDto>(tag); var albumDto = albumService.ByName <AlbumDto>(albumName); albumTagService.AddTagTo(albumDto.Id, tagDto.Id); var result = $"Tag {tag} added to {albumName}!"; return(result); }
// UploadPicture <albumName> <pictureTitle> <pictureFilePath> public string Execute(string[] data) { string albumName = data[0]; string pictureTitle = data[1]; string path = data[2]; if (!userSessionService.IsLoggedIn()) { throw new InvalidOperationException("Invalid credentials!"); } var username = userSessionService.User.Username; AlbumRoleDto roleDto = albumRoleService.GetAlbumOwner <AlbumRoleDto>(albumName, username); if (roleDto == null) { throw new InvalidOperationException("Invalid credentials!"); } var albumExists = this.albumService.Exists(albumName); if (!albumExists) { throw new ArgumentException($"Album {albumName} not found!"); } var albumId = this.albumService.ByName <AlbumDto>(albumName).Id; var picture = this.pictureService.Create(albumId, pictureTitle, path); return($"Picture {pictureTitle} added to {albumName}!"); }