Ejemplo n.º 1
0
        public void AddToPriceList(GridState gridState, IList <Filters.IFilter> filters, int priceListId)
        {
            if (!gridState.IsAnyItemMarked)
            {
                throw new NoItemMarkedException("No se ha seleccionado ningun Canal de Venta.");
            }

            MasterPriceSearchParameters msps = FilterHelper.GetSearchFilters(filters);

            ExecutePermissionValidator epv = new ExecutePermissionValidator();

            epv.ClassType     = typeof(PriceList);
            epv.KeyIdentifier = Config.SeePriceLists;

            bool  CanSeeAll    = PermissionManager.Check(epv);
            IList priceListIds = null;

            if (!CanSeeAll)
            {
                priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create);
            }

            epv               = new ExecutePermissionValidator();
            epv.ClassType     = typeof(Distributor);
            epv.KeyIdentifier = Config.DistributorInactiveStatus;
            bool isActive = PermissionManager.Check(epv);

            IList <Distributor> lst = repository.GetSelecteds(msps.Description, msps.Country, msps.PriceList, msps.PaymentTerm, msps.DistributorStatus, gridState, msps.Incoterm, msps.LookupType, msps.Categories[1] as CatalogPage, priceListIds, isActive);

            foreach (Distributor d in lst)
            {
                d.PriceList = new PriceList(priceListId);
                repository.Save(d);
            }
        }