protected void DeleteClick(object sender, EventArgs e) { _subscriptionRepository.Delete(_subscriptions); _subscriptionRepository.ResetCache(); Response.Redirect(Constant.SubscriptionListPage); }
public IActionResult Unsubscribe(int id) { int userId = BitConverter.ToInt32(HttpContext.Session.Get("userId")); Subscription subscription = subscriptionRepository.FindByUserId(userId) .Find(subs => subs.CourseId == id); subscriptionRepository.Delete(subscription); return(RedirectToAction("Courses", "Course")); }
async public Task <(IMessage, UserModel)> Process() { if (_words.Length == 1) { var subscriptions = await _repo.GetByUser(_user.Id); if (subscriptions.Any() && subscriptions.Count() <= 10) { var resorts = (new string[] { "all" }) .Concat(subscriptions.Select(s => s.GetResortName())); return(new ListMessage("What from?", "unsb ", resorts), _user); } } if (_words.Length != 2) { _user.LastCommand = string.Join(" ", _words); return(new TextMessage("Enter existing subscription link or all"), _user); } if (_words[1] != "all") { bool deleted = await _repo.Delete(_user.Id, _words[1]); if (!deleted) { return(new TextMessage("Subscription not found"), _user); } } else { var subscriptions = await _repo.GetByUser(_user.Id); await Task.WhenAll(subscriptions .ToArray() .Select(s => _repo.Delete(s.UserId, s.Uri))); } return(new TextMessage("Done"), _user); }
public ActionResult Delete(int id, SubscribeViewModel vm) { try { int currentUserId = GetCurrentUserProfileId(); vm.SubscriberUserId = currentUserId; Subscription sub = _subRepo.GetSubscription(vm); _subRepo.Delete(sub); return(RedirectToAction("Details", "Post", new { id = vm.PostId })); } catch { return(View(vm)); } }
public ActionResult RSSFeedsRemove(int id) { try { string currentUserId = HttpContext.User.Identity.GetUserId(); var delete = _subscriptionRepo.Delete(id); if (delete) { TempData["Success"] = "Unsubscribed Succesfully!"; } return(PartialView("RSSFeeds", model)); } catch (Exception ex) { TempData["Error"] = ex.Message; model = new FeedViewModel(); return(PartialView("RSSFeeds", model)); } }
public Response Delete(int SubscriptionId, bool Status) { return(repo.Delete(SubscriptionId, Status)); }
public IActionResult Delete(int id) { _subscriptionRepository.Delete(id); return(NoContent()); }
public ProductMutations(ProductRepository products, SubscriptionRepository subscriptions, UserManager <User> userManager) { Field <ProductType>( "update", description: "Update the product's details. Requires the 'Products' role.", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ProductInputType> > { Name = "product", Description = "The new details to update the product with." } ), resolve: ctx => { var id = ctx.Source; var data = ctx.GetArgument <ProductInputType.Data>("product"); var product = products.Get(id); product.Name = data.Name; product.Description = data.Description; product.Price = data.Price; product.IsSubscribable = data.CanSubscribe; products.Save(); return(product); } ).AuthorizeWith(Policies.ManageProducts); Field <SubscriptionType>( "subscribe", description: "Create or update a subscription to this product by the current user.", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "quantity", Description = "The quantity to purchase at the given frequency." }, new QueryArgument <EnumerationGraphType <SubscriptionFrequency> > { Name = "frequency", Description = "The frequency at which to purchase the product." } ), resolve: ctx => { var currentUser = ctx.UserContext.As <DepanneurUserContext>().User; var userId = userManager.GetUserId(currentUser); var productId = ctx.Source; var quantity = ctx.GetArgument <int>("quantity"); var frequency = ctx.GetArgument <SubscriptionFrequency>("frequency"); return(subscriptions.CreateOrUpdate(userId, productId, quantity, frequency)); } ); Field <UnsubscribePayloadType, UnsubscribePayloadType.Data>("unsubscribe") .Description("Unsubscribe the current user from the product.") .ResolveAsync(async ctx => { var currentUser = ctx.UserContext.As <DepanneurUserContext>().User; var userId = userManager.GetUserId(currentUser); var productId = ctx.Source; var sub = await subscriptions.GetProductSubscription(userId, productId); if (sub != null) { subscriptions.Delete(sub); } return(new UnsubscribePayloadType.Data { UserId = userId, ProductId = productId }); }); Field <ProductType>( "delete", description: "Mark the product as deleted. Requires the 'Products' role.", resolve: ctx => products.DeleteById(ctx.Source) ).AuthorizeWith(Policies.ManageProducts); Field <ProductType>( "restore", description: "Unmark the product as deleted. Requires the 'Products' role.", resolve: ctx => products.UndeleteById(ctx.Source) ).AuthorizeWith(Policies.ManageProducts); }