public ICommandResult Handle(UpdateSongCommand command)
        {
            var  singerQuery = _singerRepository.GetById(command.SingerId);
            var  albumQuery  = _albumRepository.GetById(command.AlbumId);
            Name singerName  = new Name(singerQuery.FirstName, singerQuery.LastName);

            Singer singer = new Singer(singerQuery.Id, singerName, singerQuery.Nationality, singerQuery.About, singerQuery.Image);
            Album  album  = new Album(albumQuery.Id, albumQuery.Title, null, null, albumQuery.Image);
            Song   song   = new Song(command.Id, command.Title, singer, album, command.Url, command.PublishedDate);

            AddNotifications(song.Notifications);

            if (Invalid)
            {
                return(new CommandResult(false, MessagesUtil.FormFail, Notifications));
            }

            bool result = _repository.Update(song);

            if (!result)
            {
                return(new CommandResult(false, MessagesUtil.UpdateError, Notifications));
            }

            return(new CommandResult(true, MessagesUtil.UpdatedSuccess));
        }
Exemple #2
0
 public async Task <IActionResult> Update(int id, UpdateSongCommand command)
 {
     command.Id = id;
     return(Ok(await Mediator.Send(command)));
 }
Exemple #3
0
 public ICommandResult Update([FromBody] UpdateSongCommand command)
 {
     return(_handler.Handle(command));
 }