public async Task <IActionResult> GetDocument([FromQuery(Name = "id")] int id) { var currentUser = await _identityService.GetCurrentPersonIdentityAsync(); if (currentUser == null) { return(BadRequest(new MessageDto() { Success = true, Message = "Invalid user" })); } var entity = await _documentService.GetDocumentById(id); MessageDto check = await _documentService.CheckIfClientCanView(currentUser.Id, entity.Id); if (!check.Success) { return(BadRequest(new MessageDto() { Success = true, Message = "You can view this document." })); } var model = new DocumentInfoDto() { Id = entity.Id, OwnerId = entity.OwnerId, Subject = entity.Subject, Title = entity.Title, CreatedOnUtc = entity.CreatedOnUtc.ToShortDateString(), UpdatedOnUtc = entity.UpdatedOnUtc != null?entity.UpdatedOnUtc.Value.ToShortDateString() : "", Owner = entity.Owner.FirstName + " " + entity.Owner.LastName, IsOwnerDocument = entity.OwnerId == currentUser.Id ? true : false }; return(new OkObjectResult(model)); }