예제 #1
0
        public ActionResult FontList()
        {
            var fonts = _fontService.GetAllfonts().Where(f => f.FontCulture == cultureUsed).ToList();

            return(View(fonts));
        }
예제 #2
0
        // GET: Wizard
        public ActionResult Index(int?id)
        {
            ViewBag.Currencies = _currencyRepository.Table.ToArray();

            var commonSettings = _commonSettingsRepository.Table
                                 .FirstOrDefault(s => s.CommonCulture == _cultureUsed);

            if (commonSettings == null)
            {
                _commonSettingsRepository.Create(new CommonSettingsRecord()
                {
                    DoNotAcceptAnyNewCampaigns = false,
                    CommonCulture = _cultureUsed
                });

                commonSettings = _commonSettingsRepository.Table
                                 .First(s => s.CommonCulture == _cultureUsed);
            }

            if (commonSettings.DoNotAcceptAnyNewCampaigns)
            {
                return(RedirectToAction("Oops"));
            }

            var product = _productService.GetAllProducts()
                          .Where(pr => pr.ProductHeadlineRecord.ProdHeadCulture == _cultureUsed);

            var group = _productService.GetAllProductGroups()
                        .Where(gr => gr.ProdGroupCulture == _cultureUsed);

            var color = _productService.GetAllColorsAvailable()
                        .Where(col => col.ProdColorCulture == _cultureUsed);

            //var art = _artRepository.Table.Where(a => a.ArtCulture == cultureUsed);
            var font = _fontService.GetAllfonts()
                       .Where(f => f.FontCulture == _cultureUsed);

            var swatch = _swatchService.GetAllSwatches()
                         .Where(s => s.SwatchCulture == _cultureUsed);

            var currencies = _currencyRepository.Table
                             .Where(c => c.CurrencyCulture == _cultureUsed);

            var sizes = _productService.GetAllProducts()
                        .Where(pr => pr.ProductImageRecord.ProdImgCulture == _cultureUsed);

            //var images = _productService.GetAllProducts().Where(pr => pr.);

            if (!product.Any() ||
                !group.Any() ||
                !color.Any() ||
                !font.Any() ||
                !swatch.Any() ||
                !currencies.Any() ||
                !sizes.Any())
            {
                return(RedirectToAction("Oops"));
            }

            var cost = _costService.GetCost(_cultureUsed);

            var currencyFrom = _currencyRepository.Table
                               .First(c => c.CurrencyCulture == _cultureUsed);

            var costViewModel = new AdminCostViewModel();

            if (cost != null)
            {
                costViewModel.AdditionalScreenCosts = cost.AdditionalScreenCosts.ToString();

                var dtgPrintPrice = cost.DTGPrintPrice; //_priceConversionService
                //.ConvertPrice(cost.DTGPrintPrice, currencyFrom, ExchangeRateFor.Seller);
                costViewModel.DTGPrintPrice = dtgPrintPrice.ToString();

                var firstScreenCost = cost.FirstScreenCost; //_priceConversionService
                //.ConvertPrice(cost.FirstScreenCost, currencyFrom, ExchangeRateFor.Seller);
                costViewModel.FirstScreenCost = firstScreenCost.ToString();

                var inkCost = cost.InkCost; // _priceConversionService
                //.ConvertPrice(cost.InkCost, currencyFrom, ExchangeRateFor.Seller);
                costViewModel.InkCost = inkCost.ToString();

                var laborCost = cost.LabourCost; // _priceConversionService
                //.ConvertPrice(cost.LabourCost, currencyFrom, ExchangeRateFor.Seller);
                costViewModel.LabourCost = laborCost.ToString();

                costViewModel.LabourTimePerColourPerPrint      = cost.LabourTimePerColourPerPrint;
                costViewModel.LabourTimePerSidePrintedPerPrint = cost.LabourTimePerSidePrintedPerPrint;
                costViewModel.PercentageMarkUpRequired         = cost.PercentageMarkUpRequired.ToString();
                costViewModel.PrintsPerLitre = cost.PrintsPerLitre;
                costViewModel.SalesGoal      = cost.SalesGoal;
                costViewModel.MinimumTarget  = cost.MinimumTarget;
                costViewModel.MaxColors      = cost.MaxColors;
                costViewModel = ReplaceAllCost(costViewModel);
            }

            if (id != null && id > 0)
            {
                var campaignId = (int)id;
                var campaign   = _campaignService.GetCampaignById(campaignId);
                var products   = _campaignService.GetProductsOfCampaign(campaignId).ToList();
                costViewModel.Campaign = campaign;
                costViewModel.Products = products;
            }

            if (_orchardServices.WorkContext.CurrentUser != null)
            {
                var currentUserRoles = _orchardServices.WorkContext.CurrentUser.ContentItem.As <UserRolesPart>().Roles;
                costViewModel.IsCurrentUserAdministrator = currentUserRoles.Any(r => r == "Administrator");
            }

            var facebookSettingsPart = _orchardServices.WorkContext.CurrentSite.As <FacebookSettingsPart>();

            costViewModel.FacebookClientId = facebookSettingsPart.ClientId;

            var googleSettingsPart = _orchardServices.WorkContext.CurrentSite.As <GoogleSettingsPart>();

            costViewModel.GoogleClientId = googleSettingsPart.ClientId;

            costViewModel.GoogleApiKey = "AIzaSyBijPOV5bUKPNRKTE8areEVNi81ji7sS1I";

            costViewModel.CampaignCurrencyId = _currencyRepository.Table.FirstOrDefault(aa => aa.Code == "USD") != null?_currencyRepository.Table.FirstOrDefault(aa => aa.Code == "USD").Id : _priceConversionService.CurrentUserCurrency.Id;

            costViewModel.CurrencyCulture = _currencyRepository.Table.FirstOrDefault(aa => aa.Code == "USD") != null ? "USD" : _priceConversionService.CurrentUserCurrency.Code;

            costViewModel.IsAdmin = _orchardServices.WorkContext.CurrentUser != null;


            return(View(costViewModel));
        }