示例#1
0
        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(),
            });
        }
        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));
        }