public async Task <ActionResult <UserViewModel> > Get([FromRoute] Guid id) { var user = await database.GetById <UserModel>(id); if (user == null) { return(NotFound()); } return(Ok(new UserViewModel(user))); }
public async Task <ActionResult <LinkViewModel> > Get([FromRoute] Guid id) { var link = await database.GetById <LinkModel>(id); if (link == null) { return(NotFound()); } if (!Can(Permissions.VIEW_LINKS, link)) { return(NotFound()); } return(Ok(new LinkViewModel(link, AuthorizedUser))); }
public override async Task OnActionExecutionAsync(ActionExecutingContext ctx, ActionExecutionDelegate next) { var controller = ctx.Controller as IAuthorizedController; if (controller == null) { SetUnauthorized(ctx); return; } controller.AuthClaims = await TryGetAuthClaims(ctx); if (controller.AuthClaims == null) { SetUnauthorized(ctx); return; } controller.AuthorizedUser = await database.GetById <UserModel>(controller.AuthClaims.Guid); if (controller.AuthorizedUser == null) { SetUnauthorized(ctx); return; } await base.OnActionExecutionAsync(ctx, next); }
public T GetById(object objId) { return(_databaseAccess.GetById(objId)); }