/// <summary>
        /// Gets a report of orders in the last days
        /// </summary>
        /// <param name="days">Orders in the last days</param>
        /// <param name="storeId">Store ident</param>
        /// <param name="salesEmployeeId">Sales employee ident</param>
        /// <returns>ReportPeriodOrder</returns>
        public virtual async Task <ReportPeriodOrder> GetOrderPeriodReport(int days, string storeId = "", string salesEmployeeId = "")
        {
            var      currentdate = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day);
            DateTime date        = days != 0 ?
                                   _dateTimeHelper.ConvertToUtcTime(currentdate, _dateTimeHelper.CurrentTimeZone).AddDays(-days) :
                                   _dateTimeHelper.ConvertToUtcTime(currentdate, _dateTimeHelper.CurrentTimeZone);

            var query = from o in _orderRepository.Table
                        where !o.Deleted && o.CreatedOnUtc >= date &&
                        (string.IsNullOrEmpty(storeId) || o.StoreId == storeId) &&
                        (string.IsNullOrEmpty(salesEmployeeId) || o.SeId == salesEmployeeId)
                        group o by 1 into g
                        select new ReportPeriodOrder()
            {
                Amount = g.Sum(x => x.OrderTotal / x.CurrencyRate), Count = g.Count()
            };
            var report = (await query.ToListAsync())?.FirstOrDefault();

            if (report == null)
            {
                report = new ReportPeriodOrder();
            }
            report.Date = date;
            return(report);
        }
예제 #2
0
        /// <summary>
        /// Gets a report of orders in the last days
        /// </summary>
        /// <param name="days">Orders in the last days</param>
        /// <returns>ReportPeriodOrder</returns>
        public virtual ReportPeriodOrder GetOrderPeriodReport(int days)
        {
            DateTime date = days != 0 ? _dateTimeHelper.ConvertToUserTime(DateTime.Now).AddDays(-days).Date : _dateTimeHelper.ConvertToUserTime(DateTime.Now).Date;

            var query = from o in _orderRepository.Table
                        where !o.Deleted &&
                        o.CreatedOnUtc >= date
                        group o by 1 into g
                        select new ReportPeriodOrder()
            {
                Amount = g.Sum(x => x.OrderTotal), Count = g.Count()
            };
            var report = query.ToList()?.FirstOrDefault();

            if (report == null)
            {
                report = new ReportPeriodOrder();
            }
            report.Date = date;
            return(report);
        }
예제 #3
0
        /// <summary>
        /// Gets a report of orders in the last days
        /// </summary>
        /// <param name="days">Orders in the last days</param>
        /// <param name="storeId">Store ident</param>
        /// <returns>ReportPeriodOrder</returns>
        public virtual async Task <ReportPeriodOrder> GetOrderPeriodReport(int days, string storeId)
        {
            DateTime date = days != 0 ? _dateTimeHelper.ConvertToUserTime(DateTime.Now).AddDays(-days).Date : _dateTimeHelper.ConvertToUserTime(DateTime.Now).Date;

            var query = from o in _orderRepository.Table
                        where !o.Deleted && o.CreatedOnUtc >= date &&
                        (string.IsNullOrEmpty(storeId) || o.StoreId == storeId)
                        group o by 1 into g
                        select new ReportPeriodOrder()
            {
                Amount = g.Sum(x => x.OrderTotal / x.CurrencyRate), Count = g.Count()
            };
            var report = (await query.ToListAsync())?.FirstOrDefault();

            if (report == null)
            {
                report = new ReportPeriodOrder();
            }
            report.Date = date;
            return(report);
        }