示例#1
0
        public override Task <GlobalResponse> DeleteLink(GlobalRequest request, ServerCallContext context)
        {
            var result = _linkRepository.DeleteLink(request.Id);

            return(Task.FromResult(new GlobalResponse {
                Result = result
            }));
        }
示例#2
0
        public void DeleteLinkTest()
        {
            var beforeCount = repo.GetAllLinks().Count;

            repo.DeleteLink(1);
            var afterCount = repo.GetAllLinks().Count;

            Assert.AreEqual(beforeCount - 1, afterCount);
        }
示例#3
0
        public async Task <IActionResult> DeleteLink([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var link = await _context.DeleteLink(id);

            return(Ok(link));
        }
        public async Task PurgeExpiredLinks()
        {
            var links = await _linkRepository.GetExpiredLinksAsync();

            if (links != null && links.Count() > 0)
            {
                foreach (Links l in links)
                {
                    await _linkRepository.DeleteLink(l.id);
                }
            }
        }
 public void DeleteLink(LinkModel link)
 {
     _linkRepository.DeleteLink(link.Id);
 }
示例#6
0
        public MutationObject(
            ILinkRepository linkRepository,
            IUserRepository userRepository,
            IVoteRepository voteRepository)
        {
            this.Name        = "Mutation";
            this.Description = "The mutation type, represents all updates we can make to our data.";

            this.FieldAsync <LinkType, Link>(
                "createLink",
                "Create a new link.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <LinkInputObject> >()
            {
                Name        = "link",
                Description = "The link you want to create.",
            }),
                resolve: context =>
            {
                var link = context.GetArgument <Link>("link");
                return(linkRepository.AddLink(link));
            });

            this.FieldAsync <LinkType, Link>(
                "deleteLink",
                "Delete an existent link.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> >()
            {
                Name        = "id",
                Description = "The id of the link to delete.",
            }),
                resolve: context => linkRepository.DeleteLink(context.GetArgument <int>("id")));

            this.FieldAsync <UserType, User>(
                "createUser",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <UserInputObject> > {
                Name = "user"
            }
                    ),
                resolve: context =>
            {
                var user = context.GetArgument <User>("user");
                return(userRepository.AddUser(user));
            });

            this.FieldAsync <SigninUserPayloadType, SigninUserPayload>(
                "signinUser",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SigninUserInputObject> > {
                Name = "signinUser"
            }
                    ),
                resolve: context =>
            {
                var signinUser = context.GetArgument <SigninUser>("signinUser");
                return(userRepository.SigninUser(signinUser));
            });

            this.FieldAsync <VoteType, Vote>(
                "createVote",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "userId"
            },
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "linkId"
            }
                    ),
                resolve: context =>
            {
                int userId = context.GetArgument <int>("userId");
                int linkId = context.GetArgument <int>("linkId");
                return(voteRepository.AddVote(userId, linkId, context.CancellationToken));
            });
        }
示例#7
0
 public void Delete(int id)
 {
     _linkRepo.DeleteLink(id);
 }
示例#8
0
        public IHttpActionResult DeleteLink(Guid id)
        {
            _linkRepository.DeleteLink(id);

            return(Ok());
        }
示例#9
0
        public LinkModel Execute(DeleteLinkArgument argument)
        {
            var dbLink = _linkRepository.DeleteLink(argument.LinkId);

            return(LinkHelper.GenerateLinkModel(dbLink));
        }
示例#10
0
 public IActionResult Delete(Link link)
 {
     _linkRepository.DeleteLink(link.Id);
     return(Redirect("Index"));
 }
示例#11
0
 public void DeleteLink(int linkId)
 {
     _linkRepository.DeleteLink(linkId);
 }
示例#12
0
 public IActionResult Delete(int id)
 {
     _linkRepository.DeleteLink(id);
     return(Ok());
 }