public async Task <IActionResult> Get(Guid _, Guid id) { var section = await Repository.GetImageBlock(id); return(section is null ? (IActionResult)NotFound() : Ok(ImageBlockDto.FromImageBlock(section))); }
public async Task <IActionResult> Post(ImageBlockDto dto) { Guard.AgainstNull(dto, nameof(dto)); var section = new ImageBlock( id: Guid.NewGuid(), page: dto.Page, owner: UserID, title: dto.Title, order: dto.Order ); await Repository.PersistImageBlock(section); return(CreatedAtAction(nameof(Get), dto.WithID(section.ID))); }
public async Task <IActionResult> Put(Guid id, ImageBlockDto dto) { Guard.AgainstNull(dto, nameof(dto)); var section = await Repository.GetImageBlock(id); if (section is null) { return(NotFound()); } var updatedSection = section.With( title: dto.Title, order: dto.Order ); await Repository.PersistImageBlock(updatedSection); return(Ok(dto)); }