Ejemplo n.º 1
0
 protected CityViewModel(Address address, IDevAVDbUnitOfWork unitOfWork)
 {
     Address  = address;
     Location = new GeoPoint(address.Latitude, address.Longitude);
     state    = new Lazy <DevAV.State>(() => unitOfWork.States.First(s => s.ShortName == address.State));
     crest    = new Lazy <DevAV.Crest>(() => unitOfWork.Crests.First(c => c.CityName == address.City));
 }
Ejemplo n.º 2
0
        public static IEnumerable <Item> GetSalesReport(this IDevAVDbUnitOfWork UnitOfWork)
        {
            var orders          = UnitOfWork.Orders;
            var ordersStartDate = orders.Min(x => x.OrderDate);
            var orderItems      =
                from oi in UnitOfWork.OrderItems
                join o in orders on oi.OrderId equals o.Id
                select new
            {
                Customer = o.Customer,
                Total    = oi.Total,
                FY       = ((o.OrderDate.Year - ordersStartDate.Year) * 12 + (o.OrderDate.Month - ordersStartDate.Month)) / 12
            };

            return
                (from oi in orderItems
                 group oi by new { oi.Customer, oi.FY } into g
                 select new Item
            {
                CustomerName = g.Key.Customer.Name,
                Year = ordersStartDate.Year + (int)g.Key.FY,
                Month = ordersStartDate.Month,
                Total = g.Select(o => (decimal?)o.Total).Sum() ?? 0
            });
        }
Ejemplo n.º 3
0
        public static IEnumerable <Item> GetSalesReport(this IDevAVDbUnitOfWork UnitOfWork)
        {
            var orders     = UnitOfWork.Orders;
            var orderItems =
                from oi in UnitOfWork.OrderItems
                join o in orders on oi.OrderId equals o.Id
                where (o.OrderDate >= AnalysisPeriod.Start && o.OrderDate <= AnalysisPeriod.End)
                select new
            {
                Customer = o.Customer,
                Total    = oi.Total,
                FY       = ((o.OrderDate.Year - AnalysisPeriod.Start.Year) * 12 + (o.OrderDate.Month - AnalysisPeriod.Start.Month)) / 12
            };

            return
                (from oi in orderItems
                 group oi by new { oi.Customer, oi.FY } into g
                 select new Item
            {
                CustomerName = g.Key.Customer.Name,
                Year = AnalysisPeriod.Start.Year + g.Key.FY,
                Month = AnalysisPeriod.Start.Month,
                Total = g.Select(o => (decimal?)o.Total).Sum() ?? 0
            });
        }
Ejemplo n.º 4
0
 protected override void OnEntityDeleted(long primaryKey, Order entity)
 {
     base.OnEntityDeleted(primaryKey, entity);
     if (orderItemsUnitOfWork != null)
     {
         orderItemsUnitOfWork.SaveChanges();
     }
     orderItemsUnitOfWork = null;
 }
Ejemplo n.º 5
0
        string GetNewInvoiceNumber(IDevAVDbUnitOfWork unitOfWork)
        {
            var numberStrings  = unitOfWork.Orders.Select(x => x.InvoiceNumber).ToList();
            var invoiceNumbers = numberStrings.ConvertAll(x =>
            {
                int number;
                return(int.TryParse(x, out number) ? number : 0);
            });

            return((invoiceNumbers.Max() + 1).ToString());
        }
Ejemplo n.º 6
0
        protected override void OnBeforeEntityDeleted(long primaryKey, Order entity)
        {
            base.OnBeforeEntityDeleted(primaryKey, entity);
            if (!entity.OrderItems.Any())
            {
                return;
            }
            var deletedItemKeys = entity.OrderItems.Select(x => x.Id).ToList();

            orderItemsUnitOfWork = this.UnitOfWorkFactory.CreateUnitOfWork();
            deletedItemKeys.ForEach(x => {
                var item = orderItemsUnitOfWork.OrderItems.Find(x);
                orderItemsUnitOfWork.OrderItems.Remove(item);
            });
        }
Ejemplo n.º 7
0
        public static IEnumerable <Item> GetSalesData(this IDevAVDbUnitOfWork UnitOfWork)
        {
            var orders     = UnitOfWork.Orders;
            var orderItems =
                from oi in UnitOfWork.OrderItems
                join o in orders on oi.OrderId equals o.Id
                select new { State = o.Store.Address.State, Date = o.OrderDate, Total = oi.Total };

            return
                (from oi in orderItems
                 group oi by new { oi.State, oi.Date.Year, oi.Date.Month } into g
                 select new Item {
                State = g.Key.State, Year = g.Key.Year, Month = g.Key.Month, Total = g.Select(o => (decimal?)o.Total).Sum() ?? 0
            });
        }
Ejemplo n.º 8
0
        public static IEnumerable <Item> GetFinancialData(this IDevAVDbUnitOfWork UnitOfWork)
        {
            var orders          = UnitOfWork.Orders;
            var ordersStartDate = orders.Min(x => x.OrderDate);
            var orderItems      =
                from oi in UnitOfWork.OrderItems
                join o in orders on oi.OrderId equals o.Id
                select new { Product = oi.Product, Date = o.OrderDate, Total = oi.Total };

            return
                (from oi in orderItems
                 group oi by new { oi.Product.Category, oi.Date.Year, oi.Date.Month } into g
                 select new Item {
                ProductCategory = g.Key.Category, Year = g.Key.Year, Month = g.Key.Month, Total = g.Select(x => (decimal?)x.Total).Sum() ?? 0
            });
        }
Ejemplo n.º 9
0
        public static IEnumerable <Item> GetFinancialData(this IDevAVDbUnitOfWork UnitOfWork)
        {
            var orders     = UnitOfWork.Orders;
            var orderItems =
                from oi in UnitOfWork.OrderItems
                join o in orders on oi.OrderId equals o.Id
                where (o.OrderDate >= AnalysisPeriod.Start && o.OrderDate <= AnalysisPeriod.End)
                select new { Product = oi.Product, Date = o.OrderDate, Total = oi.Total };

            return
                (from oi in orderItems
                 group oi by new { oi.Product.Category, oi.Date.Year, oi.Date.Month } into g
                 select new Item {
                ProductCategory = g.Key.Category, Year = g.Key.Year, Month = g.Key.Month, Total = g.Select(o => (decimal?)o.Total).Sum() ?? 0
            });
        }
Ejemplo n.º 10
0
 protected override void OnEntitiesLoaded(IDevAVDbUnitOfWork unitOfWork, IEnumerable <ProductInfoWithSales> entities)
 {
     base.OnEntitiesLoaded(unitOfWork, entities);
     QueriesHelper.UpdateMonthlySales(unitOfWork.OrderItems, entities);
 }
Ejemplo n.º 11
0
 public ProductAnalysisViewModel() {
     unitOfWork = DbUnitOfWorkFactory.Instance.CreateUnitOfWork();
 }
Ejemplo n.º 12
0
 public CustomerAnalysisViewModel() {
     unitOfWork = DbUnitOfWorkFactory.Instance.CreateUnitOfWork();
 }
 protected ProductAnalysisViewModel()
 {
     unitOfWork = UnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
 }
Ejemplo n.º 14
0
 public ProductAnalysisViewModel()
 {
     unitOfWork = DbUnitOfWorkFactory.Instance.CreateUnitOfWork();
 }
 void ParseDataSource()
 {
     unitOfWork = SpreadsheetDataSource.Item1;
     order      = SpreadsheetDataSource.Item2;
 }
Ejemplo n.º 16
0
 public CustomerAnalysisViewModel()
 {
     unitOfWork = DbUnitOfWorkFactory.Instance.CreateUnitOfWork();
 }
Ejemplo n.º 17
0
 public OrderMailMergeViewModel()
 {
     unitOfWork = DbUnitOfWorkFactory.Instance.CreateUnitOfWork();
 }
Ejemplo n.º 18
0
 public static CityViewModel Create(Address address, IDevAVDbUnitOfWork unitOfWork)
 {
     return(ViewModelSource.Create(() => new CityViewModel(address, unitOfWork)));
 }
Ejemplo n.º 19
0
 protected StatisticsViewModelBase()
 {
     unitOfWork = UnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
     FilterType = Period.Lifetime;
 }
 protected override IEnumerable <SalesViewModel> GetActualStatistics(IDevAVDbUnitOfWork unitOfWork)
 {
     return(QueriesHelper.GetSaleMapItemsByCity(unitOfWork.OrderItems, EntityId, SelectedAddress.Address.City, FilterType).GroupBy(mi => mi.Customer).Select(gr => new SalesViewModel(gr.Key.Name, gr.CustomSum(mi => mi.Total))));
 }
Ejemplo n.º 21
0
 protected override void OnEntitiesLoaded(IDevAVDbUnitOfWork unitOfWork, IEnumerable <CustomerInfo> entities)
 {
     base.OnEntitiesLoaded(unitOfWork, entities);
     QueriesHelper.UpdateCustomerInfoStores(entities, unitOfWork.Customers);
 }
 static DateTime LastOrderDate(IDevAVDbUnitOfWork unitOfWork)
 {
     return(unitOfWork.OrderItems.Where(x => x.Order.OrderDate <= DateTime.Today).Max(x => x.Order.OrderDate));
 }
Ejemplo n.º 23
0
 protected abstract IEnumerable <SalesViewModel> GetActualStatistics(IDevAVDbUnitOfWork unitOfWork);
 protected OrderMailMergeViewModel()
 {
     unitOfWork = UnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
 }
Ejemplo n.º 25
0
 protected CustomerAnalysisViewModel()
 {
     unitOfWork = UnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
 }