コード例 #1
0
 private List<Guid?> GetApplicablePricingTiers(SyncCostCentre syncostcentre)
 {
     var outLetTiers = new List<Guid?>();
     if (syncostcentre.CostCentreType == CostCentreType.Distributor)
     {
         var tiers =
                  _context.tblCostCentre.Where(s => s.CostCentreType == 5
                                                    && s.ParentCostCentreId == syncostcentre.Id
                                                    &&
                                                    (s.IM_Status == (int)EntityStatus.Active ||
                                                     s.IM_Status == (int)EntityStatus.Inactive))
                      .Select(s => new { s.Tier_Id, s.SpecialPricingTierId }).ToList();
         outLetTiers = tiers.Select(n => n.Tier_Id).Distinct().ToList();
         outLetTiers.AddRange(tiers.Select(n => n.SpecialPricingTierId).Distinct().ToList());
     }
     else if (syncostcentre.CostCentreType == CostCentreType.DistributorSalesman)
     {
         var routeIds = _context.tblSalemanRoute.Where(n => n.SalemanId == syncostcentre.Id
                                                            && n.IM_Status == (int)EntityStatus.Active).Select(
                                                                n => n.RouteId).Distinct().ToList();
        var tiers = _context.tblCostCentre.Where(s => routeIds.Contains(s.RouteId.Value) &&
                                                            (s.IM_Status == (int)EntityStatus.Active ||
                                                             s.IM_Status ==
                                                             (int)EntityStatus.Inactive))
             .Select(s => new { s.Tier_Id, s.SpecialPricingTierId }).ToList();
        outLetTiers = tiers.Select(n => n.Tier_Id).Distinct().ToList();
        outLetTiers.AddRange(tiers.Select(n => n.SpecialPricingTierId).Distinct().ToList());
        outLetTiers = outLetTiers.Where(p => p.HasValue && p.Value !=Guid.Empty).Distinct().ToList();
     }
     return outLetTiers;
 }
コード例 #2
0
 public List<Guid> GetOutletIds(SyncCostCentre syncCostCentre)
 {
     var query = _context.tblCostCentre.AsQueryable();
     query = query.Where(s => s.CostCentreType == (int)CostCentreType.Outlet);
     if(syncCostCentre.CostCentreType==CostCentreType.Distributor)
     {
         query = query.Where(n => n.ParentCostCentreId == syncCostCentre.Id 
             && (n.IM_Status == (int)EntityStatus.Active || n.IM_Status == (int)EntityStatus.Inactive));
     }
     else if (syncCostCentre.CostCentreType == CostCentreType.DistributorSalesman)
     {
         var routeIds = _context.tblSalemanRoute.Where(n => n.SalemanId == syncCostCentre.Id 
             && n.IM_Status == (int)EntityStatus.Active).Select(n => n.RouteId).Distinct().ToList();
         query = query.Where(n => routeIds.Contains(n.RouteId.Value));
     }
     return query.Select(s => s.Id).ToList();
 }
コード例 #3
0
 public List<Guid> GetRouteIds(SyncCostCentre syncCostCentre)
 {
     var routeIds = new List<Guid>();
     if (syncCostCentre.CostCentreType == CostCentreType.Distributor || syncCostCentre.CostCentreType == CostCentreType.Hub)
     {
         routeIds = _context.tblRoutes.Where(n => n.RegionId == syncCostCentre.TblCostCentre.Distributor_RegionId
              && (n.IM_Status == (int)EntityStatus.Active || n.IM_Status == (int)EntityStatus.Inactive)) 
             .Select(n => n.RouteID).Distinct().ToList();
     }
     else if (syncCostCentre.CostCentreType == CostCentreType.DistributorSalesman)
     {
         routeIds = _context.tblSalemanRoute.Where(n => n.SalemanId == syncCostCentre.Id
              && n.IM_Status == (int)EntityStatus.Active).Select(n => n.RouteId).Distinct().ToList();
     }
     else if (syncCostCentre.CostCentreType == CostCentreType.PurchasingClerk)
     {
         routeIds = _context.tblPurchasingClerkRoute.Where(n => n.PurchasingClerkId == syncCostCentre.Id
              && n.IM_Status == (int)EntityStatus.Active).Select(n => n.RouteId).Distinct().ToList();
     }
     return routeIds;
 }
コード例 #4
0
 public List<Guid> GetRouteIdsToDelete(SyncCostCentre syncCostCentre, DateTime from)
    {
        var routeIds = new List<Guid>();
        if (syncCostCentre.CostCentreType == CostCentreType.Distributor || syncCostCentre.CostCentreType == CostCentreType.Hub)
        {
            routeIds = _context.tblRoutes.Where(n => n.RegionId == syncCostCentre.TblCostCentre.Distributor_RegionId 
                && (n.IM_Status == (int) EntityStatus.Deleted ) 
                && n.IM_DateLastUpdated > from).Select(n => n.RouteID).Distinct().ToList();
        }
        else if (syncCostCentre.CostCentreType == CostCentreType.DistributorSalesman)
        {
            var changedoutletRoutesIds =_context.tblCostCentre
                .Where(s => s.CostCentreType == (int) CostCentreType.Outlet && s.IM_DateLastUpdated > from)
                .Select(s => s.RouteId.Value).ToList();
            var changedRouteIds = _context.tblRoutes
               .Where(s =>  s.IM_DateLastUpdated > from)
               .Select(s => s.RouteID).ToList();
            changedoutletRoutesIds.AddRange(changedRouteIds);
            changedoutletRoutesIds = changedoutletRoutesIds.Distinct().ToList();
            routeIds = _context.tblSalemanRoute.Where(n => n.SalemanId == syncCostCentre.Id
                 && n.IM_Status == (int)EntityStatus.Deleted && (changedoutletRoutesIds.Contains(n.RouteId) || n.IM_DateLastUpdated > from))
                 .Select(n => n.RouteId).Distinct().ToList();
        }
        else if (syncCostCentre.CostCentreType == CostCentreType.PurchasingClerk)
        {
            routeIds = _context.tblPurchasingClerkRoute.Where(n => n.PurchasingClerkId == syncCostCentre.Id
                 && n.IM_Status == (int)EntityStatus.Deleted && n.IM_DateLastUpdated > from)
                 .Select(n => n.RouteId).Distinct().ToList();
        }
        return routeIds;
    }
コード例 #5
0
 private List<Guid?> DiscountGroups(SyncCostCentre syncostcentre)
 {
     var discountGroups=new List<Guid?>();
     if (syncostcentre.CostCentreType == CostCentreType.Distributor)
     {
         discountGroups =
             _context.tblCostCentre.Where(s => s.CostCentreType == 5
                                               && s.ParentCostCentreId == syncostcentre.Id
                                               &&
                                               (s.IM_Status == (int) EntityStatus.Active ||
                                                s.IM_Status == (int) EntityStatus.Inactive) &&
                                               s.Outlet_DiscountGroupId != Guid.Empty)
                 .Select(s => s.Outlet_DiscountGroupId).Distinct().ToList();
     }
     else if (syncostcentre.CostCentreType == CostCentreType.DistributorSalesman)
     {
         var routeIds = _context.tblSalemanRoute.Where(n => n.SalemanId == syncostcentre.Id
                                                            && n.IM_Status == (int) EntityStatus.Active).Select(
                                                                n => n.RouteId).Distinct().ToList();
         discountGroups = _context.tblCostCentre.Where(s => routeIds.Contains(s.RouteId.Value) &&
                                                            (s.IM_Status == (int) EntityStatus.Active ||
                                                             s.IM_Status ==
                                                             (int) EntityStatus.Inactive))
             .Select(s => s.Outlet_DiscountGroupId).ToList();
         discountGroups = discountGroups.Where(p => p.HasValue && p.Value != Guid.Empty).Distinct().ToList();
     }
     return discountGroups;
 }