public IActionResult GetAll([FromQuery] QueryForTopic query) { int totalPages; var entities = repository.GetAll(new DAL.Models.QueryForTopic { CurrentPage = query.CurrentPage, PageSize = query.PageSize, SearchItemQuery = query.SearchItemQuery }, out totalPages); var dtos = new PagedTopics(); dtos.TotalPages = totalPages; foreach (var entity in entities) { var dto = new TopicForRetrieval { Id = entity.Id, Title = entity.Title, Description = entity.Description, CreatedBy = entity.CreatedBy.Username, CreatedById = entity.CreatedById }; dtos.TopicsForRetrieval.Add(dto); } return(Ok(dtos)); }
public async Task <IActionResult> Get(Guid id) { var entity = await repository.Get(id); var dto = new TopicForRetrieval { Id = entity.Id, Title = entity.Title, Description = entity.Description, CreatedBy = entity.CreatedBy.Username, CreatedById = entity.CreatedById }; return(Ok(dto)); }