예제 #1
0
        private async Task <ScheduleSummaryModel> GetScheduleSummary(string userId, DateTime dateFrom, DateTime dateTo, int placeId)
        {
            var scheduleList = await scheduleRepository.GetSchedules(dateFrom, dateTo, userId, placeId);

            int totalVisitCount       = 0;
            int scheduledVisitCount   = 0;
            int visitCount            = 0;
            int unScheduledVisitCount = 0;
            int missedVisitCount      = 0;

            foreach (var schedule in scheduleList)
            {
                if (schedule.IsVisited == true)
                {
                    totalVisitCount += 1;
                }

                if (schedule.IsScheduled == true)
                {
                    scheduledVisitCount += 1;
                }

                if (schedule.IsVisited == true && schedule.IsScheduled == true)
                {
                    visitCount += 1;
                }

                if (schedule.IsUnScheduled == true)
                {
                    unScheduledVisitCount += 1;
                }

                if (schedule.IsMissed == true)
                {
                    missedVisitCount += 1;
                }
            }

            var scheduleSummary = new ScheduleSummaryModel
            {
                MissedCount      = missedVisitCount,
                ScheduledCount   = scheduledVisitCount,
                TotalVisitCount  = totalVisitCount,
                UnscheduledCount = unScheduledVisitCount,
                VisitCount       = visitCount
            };

            return(scheduleSummary);
        }
예제 #2
0
        public async Task <ActivityModel> GetActivitiesAsync(string userId, DateTime dateFrom, DateTime dateTo, int placeId)
        {
            var allActivities = await activityRepository.GetActivities(userId, dateFrom, dateTo, placeId);

            int formCount        = 0;
            int noteCount        = 0;
            int retailAuditCount = 0;
            int orderCount       = 0;
            int photoCount       = 0;
            ScheduleSummaryModel summarySchedule = null;
            string totalOrder = "0";

            summarySchedule = await GetScheduleSummary(userId, dateFrom, dateTo, placeId);

            totalOrder = await GetOrderTotal(userId, dateFrom, dateTo, placeId);

            foreach (var activity in allActivities)
            {
                if (activity.ActivityLog == "Forms")
                {
                    formCount += 1;
                }

                if (activity.ActivityLog == "Notes")
                {
                    noteCount += 1;
                }

                if (activity.ActivityLog == "Product Retail Audit")
                {
                    retailAuditCount += 1;
                }

                if (activity.ActivityLog == "Orders")
                {
                    orderCount += 1;
                }

                if (activity.ActivityLog == "Photos")
                {
                    photoCount += 1;
                }
            }

            var activityVar = new ActivityModel
            {
                FormCount             = formCount,
                NoteCount             = noteCount,
                RetailAuditCount      = retailAuditCount,
                OrderCount            = orderCount,
                PhotoCount            = photoCount,
                TotalVisitCount       = summarySchedule.TotalVisitCount,
                MissedVisitCount      = summarySchedule.MissedCount,
                UnScheduledVisitCount = summarySchedule.UnscheduledCount,
                ScheduledVisitCount   = summarySchedule.ScheduledCount,
                VisitCount            = summarySchedule.VisitCount,
                UserId     = userId,
                OrderTotal = totalOrder
            };

            return(activityVar);
        }