Exemple #1
0
        public JsonResult GetDataForReLaunch(string campaignName)
        {
            var campaign = _campaignService.GetCampaignByAlias(campaignName);
            var products = _campaignService.GetProductsOfCampaign(campaign.Id);
            var result   = new RelaunchViewModel();
            var prodInfo = new List <object>();

            foreach (var product in products)
            {
                var prodRec = _productService.GetProductById(product.ProductRecord.Id);
                prodInfo.Add(new
                {
                    Price = product.Price,
                    BaseCostForProduct = prodRec.BaseCost,
                    ProductId          = prodRec.Id,
                    BaseCost           = product.BaseCost
                });
            }

            var tShirtCostRecord = _tshirtService.GetCost(_cultureUsed);

            result.Products         = prodInfo.ToArray();
            result.CntBackColor     = campaign.CntBackColor;
            result.CntFrontColor    = campaign.CntFrontColor;
            result.TShirtCostRecord = tShirtCostRecord;
            result.ProductCountGoal = campaign.ProductCountSold;

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        // GET: AdminCost
        public ActionResult Index()
        {
            TShirtCostRecord cost = _costService.GetCost(cultureSearch);

            if (cost == null)
            {
                return(View("Index", new AdminCostViewModel {
                }));
            }
            else
            {
                AdminCostViewModel costViewModel = new AdminCostViewModel {
                    AdditionalScreenCosts = cost.AdditionalScreenCosts.ToString(), DTGPrintPrice = cost.DTGPrintPrice.ToString(), FirstScreenCost = cost.FirstScreenCost.ToString(), InkCost = cost.InkCost.ToString(), LabourCost = cost.LabourCost.ToString(), LabourTimePerColourPerPrint = cost.LabourTimePerColourPerPrint, LabourTimePerSidePrintedPerPrint = cost.LabourTimePerSidePrintedPerPrint, PercentageMarkUpRequired = cost.PercentageMarkUpRequired.ToString(), PrintsPerLitre = cost.PrintsPerLitre, SalesGoal = cost.SalesGoal, MaxColors = cost.MaxColors, MinimumTarget = cost.MinimumTarget
                };

                return(View("Index", costViewModel));
            }
        }
Exemple #3
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));
        }