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; } }
public async Task <AlbumApplication> UpdateAsync(AlbumApplication entity) { var result = await _albumRepository.UpdateAsync(AlbumMapper.Map(entity)); return(AlbumMapper.Map(result)); }