protected void Page_Init(object sender, EventArgs e)
        {
            Session["Active"] = "SubscriptionList";
            if (PublicCustomerInfos != null && PublicCustomerInfos.IsSuperAdmin)
            {
                AddNewRow.Visible = true;
            }

            if (!IsPostBack)
            {
                Session["CurrentPageSubscription"] = 1;
                var subscriptionses = _subscriptionRepository.GetAll().Where(s => !s.IsDelete).Take(Constant.ItemPerPage).ToList();
                RptSubscriptionsListing.DataSource = subscriptionses;
                RptSubscriptionsListing.DataBind();
            }
        }
예제 #2
0
        async public Task <IActionResult> Post()
        {
            var now           = DateTimeOffset.UtcNow;
            var subscriptions = await _subscriptionRepo.GetAll();

            var users = await _userRepo.GetUsersWhoCanBeNotified(now);

            var subscriptionsForUsers = subscriptions
                                        .Join(users, s => s.UserId, u => u.Id, (s, u) => (u, s))
                                        .Where(joined => !joined.Item2.UpdatedToday(joined.Item1, now))
                                        .Select(joined => joined.Item2);
            var snowfall = await _snowfallChecker.Check(subscriptionsForUsers);

            var notifyTasks = snowfall.Select(s => notify(s.UserId, s.Subscriptions));
            var saveTasks   = snowfall
                              .SelectMany(s => _subscriptionRepo.CreateSaveTasks(s.Subscriptions));
            await Task.WhenAll(notifyTasks.Concat(saveTasks));

            return(Ok());
        }
예제 #3
0
 public IActionResult Get()
 {
     return(Ok(_subscriptionRepository.GetAll()));
 }