public IActionResult GetCurrentUser() { try { if (_user != null || _admin != null) { if (_user != null) { var avatar = _ctx.GetAvatarById(_user.Id); if (avatar != null) { return(Ok(avatar)); } return(BadRequest($"No content was found for {_user.Id}")); } if (_admin != null) { return(Ok(_admin)); } } return(Unauthorized("No user is current logged in;")); } catch (Exception ex) { _logger.LogError(Messages(WarningType.LogMessage, "LOGGIN"), ex); return(StatusCode(500, Messages(WarningType.ExceptionError, nameof(GetCurrentUser)))); } }
public IActionResult GetComment(int id) { // super try { var avatar = _ctx.GetAvatarById(_user.Id); var comments = avatar.Comments.OrderBy(c => c.Id); var comment = comments.FirstOrDefault(c => c.Id == id); if (comment == null) { var message = $"No comment with Id {id} was found."; return(NotFound(message)); } return(Ok(_mapper.Map <CommentDto>(comment))); } catch (Exception ex) { _logger.LogError($"Unable to retrieve comment: {id} by user: {_user.Id}.", ex); return(StatusCode(500, "There was an expection found at GetComment.")); } }