Ejemplo n.º 1
0
        public async Task <BaseResponse <ArtistDto> > Insert(ArtistImageModel artistImageModel)
        {
            //TODO
            BaseResponse <ArtistDto> baseResponse = new BaseResponse <ArtistDto>();
            Files files = new Files
            {
                ImageFile = artistImageModel.File
            };
            var file = await _filesService.Insert(files);

            Artist artist = new Artist
            {
                FileId = file.Id,
                Gender = artistImageModel.Gender,
                Info   = artistImageModel.Info,
                Name   = artistImageModel.Name
            };
            var result = await _artistRepository.Insert(artist);

            var fileDto = _mapper.Map <FilesDto>(file);
            //new FilesDto { Id = file.Id, Path = file.Path };
            var artistDto = new ArtistDto {
                File = fileDto, Gender = result.Gender, Id = result.Id, Info = result.Info, Name = result.Name
            };

            baseResponse.Result = artistDto;
            return(baseResponse);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> store([FromForm] ArtistImageModel artistImageModel)
        {
            try
            {
                _logger.LogInfo(ControllerContext.ActionDescriptor.DisplayName);
                if (ModelState.IsValid)
                {
                    var result = await _artistService.Insert(artistImageModel);

                    //await _musicTypesHub.Clients.All.SendAsync("newMusicTypeAdded",newMusicTypes);
                    InfoLog($"{ControllerContext.ActionDescriptor.DisplayName} ArtistCreated Name : {result.Result.Name}  Id : {result.Result.Id} Info : {result.Result.Info} and Gender : {result.Result.Gender}");
                    return(Ok(result));
                }
                return(BadRequest());
            }
            catch (Exception exception)
            {
                return(ErrorInternal(exception, $"{ControllerContext.ActionDescriptor.DisplayName} Exception Message : {exception.Message} - {exception.InnerException}"));
            }
        }