public GoogleAnalyticsEnableReportingDataModel GetGoogleAnalyticsViewModel(TempCart tempCart) { if (tempCart == null || !tempCart.IsCompleted) { return(new GoogleAnalyticsEnableReportingDataModel()); } var model = new GoogleAnalyticsEnableReportingDataModel(); if (tempCart.EventPackageId.HasValue) { model.EventPackage = _eventPackageRepository.GetById(tempCart.EventPackageId.Value); } if (!string.IsNullOrEmpty(tempCart.TestId)) { var testIdStrings = tempCart.TestId.Split(new[] { ',' }); if (testIdStrings.Any()) { long id; var testIds = testIdStrings.Where(p => long.TryParse(p, out id)).Select(p => Convert.ToInt64(p)).ToArray(); if (testIds.Count() > 0) { model.EventTests = _eventTestRepository.GetbyIds(testIds); } } } if (!string.IsNullOrEmpty(tempCart.ProductId)) { var productIdStrings = tempCart.ProductId.Split(new[] { ',' }); if (productIdStrings.Any()) { long id; var productIds = productIdStrings.Where(p => long.TryParse(p, out id)).Select(p => Convert.ToInt64(p)).ToArray(); if (productIds.Count() > 0) { model.Products = _productRepository.GetByIds(productIds); } } } if (tempCart.ShippingId.HasValue && tempCart.ShippingId.Value > 0) { model.Shipping = _shippingOptionRepository.GetById(tempCart.ShippingId.Value).Price; } Order order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value); model.TotalPrice = order.DiscountedTotal; model.CustomerId = tempCart.CustomerId.Value; var customer = _customerRepository.GetCustomer(tempCart.CustomerId.Value); model.Address = _addressService.GetAddress(customer.Address.Id); return(model); }
public SourceCodeListModel Get(SourceCodeListModelFilter filter, int pageNumber, int pageSize, out long totalRecords) { var sourceCodes = _sourceCodeRepository.GetbyFilter(filter, pageNumber, pageSize, out totalRecords); if (sourceCodes == null || sourceCodes.Count() < 1) { return(null); } var packageids = sourceCodes.Where(sc => sc.PackageDiscounts != null).SelectMany(sc => sc.PackageDiscounts.Select(pd => pd.Id)).ToArray(); var packages = packageids.Count() > 0 ? _packageRepository.GetByIds(packageids) : null; var testIds = sourceCodes.Where(sc => sc.TestDiscounts != null).SelectMany(sc => sc.TestDiscounts.Select(pd => pd.Id)).ToArray(); var tests = testIds.Count() > 0 ? _testRepository.GetByIds(testIds) : null; var shippingOptionIds = sourceCodes.Where(sc => sc.ShippingDiscounts != null).SelectMany(sc => sc.ShippingDiscounts.Select(sd => sd.Id)).ToArray(); var shippingOptions = shippingOptionIds.Count() > 0 ? _shippingOptionRepository.GetByIds(shippingOptionIds) : null; var productIds = sourceCodes.Where(sc => sc.ProductDiscounts != null).SelectMany(sc => sc.ProductDiscounts.Select(pd => pd.Id)).ToArray(); var products = productIds.Count() > 0 ? _electronicProductRepository.GetByIds(productIds) : null; return(_sourceCodeFactory.Create(sourceCodes, packages, tests, shippingOptions, products)); }
public SourceCodeApplyEditModel GetSourceCodeApplied(TempCart tempCart, SourceCodeApplyEditModel sourceCodeModel = null) { var model = new SourceCodeApplyEditModel { SignUpMode = (int)SignUpMode.Online, SourceCodeHelpDescription = _toolTipRepository.GetToolTipContentByTag(ToolTipType.SourceCodeHelp) }; if (tempCart == null) { return(model); } if (tempCart.EventId.HasValue) { model.EventId = tempCart.EventId.Value; } if (tempCart.CustomerId.HasValue) { model.CustomerId = tempCart.CustomerId.Value; } decimal orderTotal = 0; if (tempCart.EventPackageId.HasValue) { var eventPackage = _eventPackageRepository.GetById(tempCart.EventPackageId.Value); model.Package = new OrderedPair <long, decimal>(eventPackage.PackageId, eventPackage.Price); orderTotal += model.Package.SecondValue; } if (!string.IsNullOrEmpty(tempCart.TestId)) { var eventTestIds = tempCart.TestId.Split(new[] { ',' }).Select(t => Convert.ToInt64(t.Trim())); var eventTests = _eventTestRepository.GetbyIds(eventTestIds); model.SelectedTests = eventTests.Select(et => new OrderedPair <long, decimal>(et.TestId, tempCart.EventPackageId.HasValue ? et.WithPackagePrice : et.Price)).ToArray(); orderTotal += model.SelectedTests.Sum(s => s.SecondValue); } if (tempCart.ShippingId.HasValue && tempCart.ShippingId.Value > 0) { var shippingOption = _shippingOptionRepository.GetById(tempCart.ShippingId.Value); model.ShippingAmount = shippingOption.Price; orderTotal += model.ShippingAmount; } if (!string.IsNullOrEmpty(tempCart.ProductId)) { var productids = tempCart.ProductId.Split(new[] { ',' }).Select(t => Convert.ToInt64(t.Trim())); var products = _productRepository.GetByIds(productids); model.ProductAmount = products.Sum(p => p.Price); orderTotal += model.ProductAmount; } model.OrderTotal = orderTotal; if (sourceCodeModel != null && sourceCodeModel.SourceCodeId > 0) { var sourceCode = _sourceCodeRepository.GetSourceCodeById(sourceCodeModel.SourceCodeId); model.SourceCode = sourceCode.CouponCode; model = ApplySourceCode(model); } else if (tempCart.SourceCodeId.HasValue && tempCart.SourceCodeId > 0) { var sourceCode = _sourceCodeRepository.GetSourceCodeById(tempCart.SourceCodeId.Value); model.SourceCode = sourceCode.CouponCode; model = ApplySourceCode(model); } return(model); }