Esempio n. 1
0
        public AnalyticsDto Analytic()
        {
            AnalyticsDto bonus = new AnalyticsDto();

            bonus.MostTrending   = MostTrending();
            bonus.MostLiked      = MostLiked();
            bonus.ActiveUser     = MostTweetByPerson();
            bonus.TotaltweetsDay = TotalTweetsDay();
            return(bonus);
        }
Esempio n. 2
0
 public void PushToQueue(string topic, AnalyticsDto analyticsDto) => this._queueProvider.Push <AnalyticsDto>(topic, analyticsDto);
Esempio n. 3
0
 public Task <string> CreateAsync(AnalyticsDto analyticsDto) => this.CreateAsync(analyticsDto, CancellationToken.None);
Esempio n. 4
0
        public async Task <string> CreateAsync(AnalyticsDto analyticsDto, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            return(await this._commandHandler.CreateAsync(analyticsDto.ToEntity()));;
        }
Esempio n. 5
0
        public AnalyticsDto GetAnalytics(ExpenseListViewCriteria criteria)
        {
            var currentUser = this.userRepository.GetAllIncluding(x => x.Role).Where(x => x.Id == (int)this.CurrentUserId).FirstOrDefault();

            var query = this.entityRepository.GetAllIncluding(x => x.Provider,
                                                              x => x.User,
                                                              x => x.SyncStatus,
                                                              x => x.Company).
                        Where(x => x.Company.Id == criteria.CompanyId &&
                              DbFunctions.DiffDays(criteria.StartDate, x.Date) >= 0 &&
                              DbFunctions.DiffDays(criteria.EndDate, x.Date) <= 0);

            if (currentUser.Role.Description == "Usuario")
            {
                query = query.Where(x => x.User.Id == (int)this.CurrentUserId);
            }
            if (query.Count() == 0)
            {
                return(new AnalyticsDto());
            }
            var results = query.GroupBy(x => x.User.Id).ToList();

            var analyticsDto = new AnalyticsDto();

            analyticsDto.Vendors = new List <VendorAnalyticsDto>();

            foreach (var userExpenses in results)
            {
                var user            = this.userRepository.GetSingle(userExpenses.Key);
                var vendorAnalytics = new VendorAnalyticsDto {
                    FullName = user.FirstName + " " + user.LastName
                };

                foreach (var expense in userExpenses)
                {
                    var dbExpense = this.entityRepository.GetAllIncluding(x => x.Category).Where(x => x.Id == expense.Id).FirstOrDefault();
                    switch (dbExpense.Category.Description)
                    {
                    case "Comida":
                        analyticsDto.TotalFood    = analyticsDto.TotalFood + expense.Total;
                        vendorAnalytics.TotalFood = vendorAnalytics.TotalFood + expense.Total;
                        break;

                    case "Alojamiento":
                        analyticsDto.TotalHotel    = analyticsDto.TotalHotel + expense.Total;
                        vendorAnalytics.TotalHotel = vendorAnalytics.TotalHotel + expense.Total;
                        break;

                    case "Combustible":
                        analyticsDto.TotalFuel    = analyticsDto.TotalFuel + expense.Total;
                        vendorAnalytics.TotalFuel = vendorAnalytics.TotalFuel + expense.Total;
                        break;

                    default:
                        analyticsDto.TotalOther    = analyticsDto.TotalOther + expense.Total;
                        vendorAnalytics.TotalOther = vendorAnalytics.TotalOther + expense.Total;
                        break;
                    }
                }
                analyticsDto.Vendors.Add(vendorAnalytics);
            }

            return(analyticsDto);
        }