示例#1
0
        public async Task <IActionResult> Edit(string id, SongFormModel model)
        {
            if (model.File != null &&
                (!model.File.IsSong() || model.File.Length > SongMaxLength))
            {
                return(View(model)
                       .WithErrorMessage($"Your submission should be an audio file and no more than {SongMaxMBs} MBs in size!"));
            }

            string fileExtension = model.File
                                   .GetFileExtension();

            EditSong command = new EditSong()
            {
                Title         = model.Title,
                FileExtension = fileExtension,
                ReleasedYear  = model.ReleasedYear,
                Singer        = model.Singer,
                SongFile      = model.File?.ToByteArray(),
                SongId        = id
            };

            string message = await this.CallServiceAsync(
                async() => await this.editSong.ExecuteAsync(command));

            if (message != null)
            {
                return(View()
                       .WithErrorMessage(message));
            }

            return(View()
                   .WithSuccessMessage("Song edited successfully."));
        }
示例#2
0
    private void Edit(object sender, EventArgs e)
    {
        try
        {
            Button button      = (Button)sender;
            string name        = "";
            string artist      = "";
            char   separator   = " ".ToCharArray()[0];
            string buttonLabel = "";

            if (button.Name == "1")
            {
                buttonLabel = button21.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "2")
            {
                buttonLabel = button22.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "3")
            {
                buttonLabel = button23.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "4")
            {
                buttonLabel = button24.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            XDocument document = new XDocument(new XElement("Data",
                                                            new XElement("opCode", 25),
                                                            new XElement("SongName", name),
                                                            new XElement("Artist", artist)));
            SocketClient.GetSocketClient().send(document);

            EditSong editSong = new EditSong(name, artist, page);
            document = XMLGenerator.RequestSongs(page);
            UpdateSongs(document);
        }
        catch (Exception)
        {
            AlertWindow alertWindow = new AlertWindow("Error: No se pudo eliminar el elemento o este no existe, por favor reintentar");
        }
    }
示例#3
0
        private async void ExecuteEditSong(object parameter)
        {
            EditSong editSongDialog = new EditSong(this);

            await editSongDialog.ShowAsync();
        }