コード例 #1
0
ファイル: AlbumMapper.cs プロジェクト: JorgeBritezG/ImagePick
        public static Album Map(AlbumApplication dto)
        {
            if (dto.User != null)
            {
                if (dto.User.Albums != null)
                {
                    dto.User.Albums = null;
                }
            }

            return(new Album()
            {
                Id = dto.Id,
                CreatedAt = dto.CreatedAt,
                Name = dto.Name.Trim(),
                UserId = dto.UserId,
                User = dto.User == null ? null : UserMapper.Map(dto.User),
                Images = dto.Images?.Select(ImageMapper.Map).ToList(),
            });
        }
コード例 #2
0
        public async Task <ActionResult <AlbumApplication> > Put(
            [FromBody] AlbumApplication model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var result = await _albumService.UpdateAsync(model);

                return(Created("", result));
            }
            catch (Exception ex)
            {
                return(Conflict(ex.Message));

                throw;
            }
        }
コード例 #3
0
        public async Task <AlbumApplication> UpdateAsync(AlbumApplication entity)
        {
            var result = await _albumRepository.UpdateAsync(AlbumMapper.Map(entity));

            return(AlbumMapper.Map(result));
        }