Exemple #1
0
        public async Task <List <ProspectFollowup> > GetOverdueRemindersAsync()
        {
            CriteriaBuilder         criteriaBuilder = new CriteriaBuilder();
            List <ProspectFollowup> followups       = await GetManyByCriteria(
                criteriaBuilder
                .AddDateCriterion("ReminderTime", DateTime.Now, ConjunctionsEnum.And,
                                  Operators.LessThanOrEqualTo, true, true));

            if (followups == null || followups.Count == 0)
            {
                Logger.Debug("There are no followup reminders");
                return(new List <ProspectFollowup>());
            }

            Logger.Debug("Number of over due reminders is ~".GetFormated(followups.Count));
            string[] prospectIds = followups.Where(followup => followup.ProspectId != default(Guid))
                                   .Select(a => a.ProspectId.ToString())
                                   .ToArray();

            Logger.Debug("No null prospect ids count is ~".GetFormated(prospectIds.Length));

            criteriaBuilder = new CriteriaBuilder();

            List <Prospect> prospects = await new ProspectsController().GetManyByCriteria(criteriaBuilder
                                                                                          .Add("Id", prospectIds, ConjunctionsEnum.And, Operators.In));

            if (prospects == null || prospects.Count == 0)
            {
                return(new List <ProspectFollowup>());
            }

            return
                (followups.Where(followup => prospects.Select(prosp => prosp.Id).Contains(followup.ProspectId)).ToList());
        }
Exemple #2
0
        public async Task <List <SalesAppNotification> > GetAllOverdueNotificationsAsync(NotificationTypes notificationType = default(NotificationTypes))
        {
            CriteriaBuilder criteriaBuilder = new CriteriaBuilder();

            List <SalesAppNotification> overdueNotifications = await GetManyByCriteria
                                                               (
                criteriaBuilder
                .AddDateCriterion("NotificiationTime", DateTime.Now, ConjunctionsEnum.And,
                                  Operators.LessThanOrEqualTo, true, true)
                .AddIfTrue(notificationType != default(NotificationTypes), "NotificationType", (int)notificationType)
                .Add("NotificationStatus", (int)NotificationStatus.Viewed, ConjunctionsEnum.And, Operators.NotEqualTo)
                                                               ) ?? new List <SalesAppNotification>();

            return(overdueNotifications);
        }
Exemple #3
0
        public override async Task <SaveResponse <Stat> > SaveAsync(Stat model)
        {
            model.Date = model.Date.ToMidnight();
            CriteriaBuilder criteriaBuilder = new CriteriaBuilder();

            criteriaBuilder.AddDateCriterion("Date", model.Date);
            List <Stat> stats = await GetManyByCriteria(criteriaBuilder);

            Logger.Debug("Pre-existing stats to delete = '~'".GetFormated(stats.Count));
            foreach (var stat in stats)
            {
                await DeleteAsync(stat);
            }

            return(await base.SaveAsync(model));
        }