public async Task <IActionResult> CreateMusicAsync([FromBody] CreateMusicCommand command)
        {
            try
            {
                if (string.IsNullOrEmpty(command.Name))
                {
                    command.Name = string.Empty;
                }

                if (command.Title == null)
                {
                    command.Title = string.Empty;
                }
                if (command.Album == null)
                {
                    command.Album = string.Empty;
                }
                if (command.PublishingYear == null)
                {
                    command.PublishingYear = string.Empty;
                }

                Enum.TryParse <CreatureTypes>(command.CreatureType, true, out CreatureTypes creatureType);
                Enum.TryParse <OwnerTypes>(command.OwnerType, true, out OwnerTypes ownerTypes);

                var result = await musicService.Create(
                    command.Name,
                    command.Album,
                    command.PublishingYear,
                    command.OwnerId,
                    command.LicenceLink,
                    command.MusicLink,
                    command.DemoLink,
                    command.Key1,
                    command.Key2,
                    command.FullKey,
                    creatureType,
                    ownerTypes);

                return(Ok(new { MusicId = result }));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateMusic([FromBody] CreateMusicCommand command)
        {
            var result = await _mediator.Send(command);

            return(Ok(result));
        }