Example #1
0
 public CalculatePrices(PriceListRepository priceLists, OfferModifiers offerModifiers,
                        ExchangeRateProvider exchangeRates)
 {
     _priceLists     = priceLists;
     _offerModifiers = offerModifiers;
     _exchangeRates  = exchangeRates;
 }
Example #2
0
        public void AddPriceList(PriceList priceList)
        {
            var priceListRep = new PriceListRepository();
            var category     = _stockService.GetCategoryByName(priceList.Product.Category.Name);

            if (category == null)
            {
                var categoryAdd = new Category {
                    Name = priceList.Product.Category.Name
                };
                var categoryRep = new CategoryRepository();
                category = categoryRep.Add(categoryAdd);
            }

            var product = _stockService.GetProductByName(priceList.Product.Name);

            if (product == null)
            {
                var productAdd = new Product {
                    Name = priceList.Product.Name, Category = category
                };
                var productRep = new ProductRepository();
                product = productRep.Add(productAdd);
            }

            priceList.Product = product;
            priceListRep.Add(priceList);
        }
Example #3
0
        public List <PriceList> GetProducts()
        {
            var priceListRepo = new PriceListRepository();
            var pricesList    = priceListRepo
                                .Get()
                                .Include(p => p.Product)
                                .Include(p => p.Product.Category)
                                .ToList();

            return(pricesList);
        }
        public void  CopyPriceList(string touroperator, string sourceSiteCode, string sourceOfferCode, PriceListType sourcePriceListType,
                                   string targetSiteCode, string targetUitCode, string targetOfferCode, PriceListType targetPriceListType,
                                   decimal factor)
        {
            //uzmi cijene koje treba da budu kopirane
            var sourcePriceList = PriceListRepository.GetPriceList(touroperator, sourceSiteCode, sourceOfferCode, sourcePriceListType);
            //uzmi id od cjenovnika u koji treba da bude kopirano
            string targetId = PriceListRepository.GetPriceList(touroperator, targetSiteCode, targetOfferCode, targetPriceListType).id;

            //kopiraj cjene u aktuelni cjenovnik
            PriceListRepository.ReplacePriceList(sourcePriceList, targetId, factor);
        }
Example #5
0
        //public void UpdateRestTrxFee()
        //{

        //    try
        //    {
        //        var list =TransactionsViewRepository.GetMany(
        //                    x => x.Fee == 0 && x.Amount > 0
        //                        && x.TransactionDate.Year >= 2014
        //                    //x.TransactionTypeId == (byte) BillingEnums.eTransactionTypes.InitialSubscriptionPayment &&
        //                       && (x.PaymentMethodId == (byte)BillingEnums.ePaymentMethods.Credit_Card) || x.PaymentMethodId == (byte)BillingEnums.ePaymentMethods.Saved_Instrument).ToList();
        //        var cnt = 0;

        //        foreach (var row in list)
        //        {
        //            var trx = _paypalManageServies.GetRestPaymentDetails(row.ExternalTransactionID);

        //            //if(trx ==null || trx.Ack != AckCodeType.SUCCESS) continue;

        //            //var fee = trx.PaymentTransactionDetails.PaymentInfo.FeeAmount.value;

        //            //if(fee==null) continue;

        //            //var entity = TransactionRepository.GetById(row.TransactionId);

        //            //if(entity==null) continue;

        //            //entity.Fee = Convert.ToDecimal(fee);

        //            //entity.UpdateDate = DateTime.Now;

        //            //if(!TransactionRepository.UnitOfWork.CommitAndRefreshChanges()) continue;
        //            cnt++;
        //        }
        //    }
        //    catch (Exception)
        //    {

        //    }
        //}

        //public void ImportPrices()
        //{
        //    using (var context = new lfeAuthorEntities())
        //    {
        //        #region courses
        //        var courses = context.Courses.Where(x => !x.IsFreeCourse).ToList();

        //        foreach (var course in courses)
        //        {
        //            var courseId = course.Id;

        //            BILL_ItemsPriceList entity;

        //            if (course.PriceUSD != null)
        //            {
        //                if (context.BILL_ItemsPriceList.Any(x => x.ItemId == courseId
        //                                                        && x.ItemTypeId == (byte)BillingEnums.ePurchaseItemTypes.COURSE
        //                                                        && x.PriceTypeId == (byte)BillingEnums.ePricingTypes.ONE_TIME
        //                                                        && x.CurrencyId == DEFAULT_CURRENCY_ID)
        //                                                    ) continue;


        //                entity = new BILL_ItemsPriceList
        //                {
        //                    ItemId       = courseId
        //                    ,ItemTypeId  = (byte)BillingEnums.ePurchaseItemTypes.COURSE
        //                    ,PriceTypeId = (byte)BillingEnums.ePricingTypes.ONE_TIME
        //                    ,Price       = (decimal) course.PriceUSD
        //                    ,CurrencyId  = DEFAULT_CURRENCY_ID
        //                    ,IsDeleted   = false
        //                    ,AddOn       = DateTime.Now
        //                };

        //                context.BILL_ItemsPriceList.Add(entity);

        //                context.SaveChanges();
        //            }

        //            if (course.MonthlySubscriptionPriceUSD == null) continue;


        //            if (context.BILL_ItemsPriceList.Any(x => x.ItemId == courseId
        //                                                     && x.ItemTypeId == (byte)BillingEnums.ePurchaseItemTypes.COURSE
        //                                                     && x.PriceTypeId == (byte)BillingEnums.ePricingTypes.SUBSCRIPTION
        //                                                     && x.PeriodTypeId == (byte)BillingEnums.eBillingPeriodType.MONTH
        //                                                     && x.CurrencyId == DEFAULT_CURRENCY_ID)
        //                ) continue;


        //                entity = new BILL_ItemsPriceList
        //                {
        //                    ItemId        = courseId
        //                    ,ItemTypeId   = (byte)BillingEnums.ePurchaseItemTypes.COURSE
        //                    ,PriceTypeId  = (byte)BillingEnums.ePricingTypes.SUBSCRIPTION
        //                    ,PeriodTypeId = (byte)BillingEnums.eBillingPeriodType.MONTH
        //                    ,Price        = (decimal) course.MonthlySubscriptionPriceUSD
        //                    ,CurrencyId   = DEFAULT_CURRENCY_ID
        //                    ,IsDeleted    = false
        //                    ,AddOn        = DateTime.Now
        //                };

        //                context.BILL_ItemsPriceList.Add(entity);

        //                context.SaveChanges();
        //        }
        //        #endregion

        //        #region bundle
        //        var bundles = context.CRS_Bundles.ToList();

        //        foreach (var bundle in bundles)
        //        {
        //            var courseId = bundle.BundleId;

        //            BILL_ItemsPriceList entity;

        //            if (bundle.Price != null)
        //            {
        //                if (context.BILL_ItemsPriceList.Any(x => x.ItemId == courseId
        //                                                        && x.ItemTypeId == (byte)BillingEnums.ePurchaseItemTypes.BUNDLE
        //                                                        && x.PriceTypeId == (byte)BillingEnums.ePricingTypes.ONE_TIME
        //                                                        && x.CurrencyId == DEFAULT_CURRENCY_ID)
        //                                                    ) continue;


        //                entity = new BILL_ItemsPriceList
        //                {
        //                    ItemId       = courseId
        //                    ,ItemTypeId  = (byte)BillingEnums.ePurchaseItemTypes.BUNDLE
        //                    ,PriceTypeId = (byte)BillingEnums.ePricingTypes.ONE_TIME
        //                    ,Price       = (decimal) bundle.Price
        //                    ,CurrencyId  = DEFAULT_CURRENCY_ID
        //                    ,IsDeleted   = false
        //                    ,AddOn       = DateTime.Now
        //                };

        //                context.BILL_ItemsPriceList.Add(entity);

        //                context.SaveChanges();
        //            }

        //            if (bundle.MonthlySubscriptionPrice == null) continue;


        //            if (context.BILL_ItemsPriceList.Any(x => x.ItemId == courseId
        //                                                     && x.ItemTypeId == (byte)BillingEnums.ePurchaseItemTypes.BUNDLE
        //                                                     && x.PriceTypeId == (byte)BillingEnums.ePricingTypes.SUBSCRIPTION
        //                                                     && x.PeriodTypeId == (byte)BillingEnums.eBillingPeriodType.MONTH
        //                                                     && x.CurrencyId == DEFAULT_CURRENCY_ID)
        //                ) continue;


        //                entity = new BILL_ItemsPriceList
        //                {
        //                    ItemId        = courseId
        //                    ,ItemTypeId   = (byte)BillingEnums.ePurchaseItemTypes.BUNDLE
        //                    ,PriceTypeId  = (byte)BillingEnums.ePricingTypes.SUBSCRIPTION
        //                    ,PeriodTypeId = (byte)BillingEnums.eBillingPeriodType.MONTH
        //                    ,Price        = (decimal) bundle.MonthlySubscriptionPrice
        //                    ,CurrencyId   = DEFAULT_CURRENCY_ID
        //                    ,IsDeleted    = false
        //                    ,AddOn        = DateTime.Now
        //                };

        //                context.BILL_ItemsPriceList.Add(entity);

        //                context.SaveChanges();
        //        }
        //        #endregion
        //    }
        //}

        public void UpdateFreeCourses()
        {
            try
            {
                var lines = CourseRepository.GetMany(x => x.IsFreeCourse).ToList();

                foreach (var course in lines)
                {
                    var current  = course;
                    var isExists = PriceListRepository.IsAny(x => x.ItemId == current.Id &&
                                                             x.ItemTypeId == (byte)BillingEnums.ePurchaseItemTypes.COURSE &&
                                                             x.PriceTypeId == (byte)BillingEnums.ePricingTypes.FREE &&
                                                             !x.IsDeleted);

                    if (isExists)
                    {
                        continue;
                    }

                    var dto = new PriceLineDTO
                    {
                        ItemId = course.Id
                        ,
                        ItemType = BillingEnums.ePurchaseItemTypes.COURSE
                        ,
                        PriceType = BillingEnums.ePricingTypes.FREE
                        ,
                        Price = 0
                        ,
                        Currency = new BaseCurrencyDTO {
                            CurrencyId = DEFAULT_CURRENCY_ID
                        }
                    };

                    var entity = dto.Token2PriceLineEntity();

                    PriceListRepository.Add(entity);

                    PriceListRepository.UnitOfWork.CommitAndRefreshChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private LineItem Sku2LineItem(Item sku, decimal quantity)
        {
            var session = CustomerSessionService.CustomerSession;
            var price   = PriceListRepository.FindLowestPrice(session != null ? session.Pricelists : null, sku.ItemId, quantity);
            var retVal  = new LineItem
            {
                CatalogItemId   = sku.ItemId,
                CatalogItemCode = sku.Code,
                DisplayName     = sku.Name,
                Quantity        = quantity,
                Catalog         = sku.CatalogId,
                MaxQuantity     = sku.MaxQuantity,
                MinQuantity     = sku.MinQuantity,
                PlacedPrice     = price != null ? (price.Sale ?? price.List) : 0,
                ListPrice       = price != null ? (price.Sale ?? price.List) : 0,
                CatalogOutline  = OutlineBuilder.BuildCategoryOutline(CustomerSessionService.CustomerSession.CatalogId, sku.ItemId).ToString()
            };

            return(retVal);
        }
Example #7
0
 public List <Data> GetTouristCodes()
 {
     return(PriceListRepository.GetDataTouristOperators());
 }
 public void SavePartialModelSpecialPrices(string id, List <SpecialPrices> partModelList)
 {
     PriceListRepository.SavePartialPriceListModel(id, partModelList);
 }
 public void SavePartialModelSeasonUnitCondition(string id, List <SeasonUnitCondition> partModelList)
 {
     PriceListRepository.SavePartialPriceListModel(id, partModelList);
 }
 public void SavePartialModelSeasonUnitAvailability(string id, List <SeasonUnitAvailability> partModelList)
 {
     PriceListRepository.SavePartialPriceListModel(id, partModelList);
 }
 public void SavePartialModelPaymentMode(string id, List <PaymentMode> partModelList)
 {
     PriceListRepository.SavePartialPriceListModel(id, partModelList);
 }
 public string GetPriceListId(string touroperator, string siteCode, string offerCode, PriceListType pType)
 {
     return(PriceListRepository.GetModel(touroperator, siteCode, offerCode, pType).id);
 }
 public PriceListModel GetModel(string tourOperatorCode, string siteCode, string offerCode, PriceListType pType)
 {
     return(PriceListRepository.GetModel(tourOperatorCode, siteCode, offerCode, pType));
 }
Example #14
0
 public List <Data> GetTouristSites(string touroperator)
 {
     return(PriceListRepository.GetDataSiteCodes(touroperator));
 }
 public void SavePartialModelSeasonUnitService(string id, List <SeasonUnitService> partModelList)
 {
     PriceListRepository.SavePartialPriceListModel(id, partModelList);
 }
Example #16
0
 public List <Data> GetUnitOffers(string sitecode)
 {
     return(PriceListRepository.GetDataOfferCodes(sitecode));
 }
Example #17
0
 public List <Data> GetPriceListTypes(string sitecode, string offercode)
 {
     return(PriceListRepository.GetDataPriceListTypes(sitecode, offercode));
 }