/// <summary> /// Resolves all mutations on guest accesses. /// </summary> /// <param name="graphQlMutation"></param> public void ResolveMutation(GraphQlMutation graphQlMutation) { // FLAG CHANNEL graphQlMutation.FieldAsync <BooleanGraphType>( "flagChannel", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "channelId" } ), resolve: async(context) => { // read user context dictionary var userContext = (GraphQlUserContext)context.UserContext; string userId = userContext.GetUserId(); // require user to be authenticated if (userId == null) { return(false); } await _flagRepository.AddFlag( context.GetArgument <string>("channelId"), userId ); return(true); }); }
public BasicResponse <FlagInfo> AddFlag(FlagAddRequest flagrequest) { var _flag = ObjectConverter.Copy <FlagInfo, FlagModel>(flagrequest.FlagInfo); var resultflag = _Repository.AddFlag(_flag); var flagresponse = new BasicResponse <FlagInfo>(); flagresponse.Data = ObjectConverter.Copy <FlagModel, FlagInfo>(resultflag); return(flagresponse); }