// AddTagTo <albumName> <tag> public string Execute(string[] data) { string albumName = data[0]; string tagName = data[1].ValidateOrTransform(); if (!AuthenticationService.IsAuthenticated()) { throw new InvalidOperationException("Invalid credentials"); } if (!tagService.TagExists(tagName) || !albumService.AlbumExists(albumName)) { throw new ArgumentException("Either tag or album do not exist!"); } User currentUser = AuthenticationService.GetCurrentUser(); List <string> owners = albumService.GetAlbumOwners(albumName); if (!owners.Contains(currentUser.Username)) { throw new InvalidOperationException("Invalid credentials"); } tagService.AddTagToAlbum(albumName, tagName); return("Tag " + tagName + " added to " + albumName + "!"); }
// AddTagTo <albumName> <tag> public string Execute(string[] data) { var albumName = data[0]; var tagName = data[1]; if (!albumService.IsAlbumExists(albumName)) { throw new ArgumentException($"Album {albumName} do not exist!"); } if (!tagService.IsTagExisting(tagName)) { throw new ArgumentException($"Tag {tagName} do not exist!"); } tagService.AddTagToAlbum(tagName, albumName); return($"Tag {tagName} added to {albumName}!"); }