public ActionResult Edit() { TShirtCostRecord cost = _costService.GetCost(cultureSearch); if (cost == null) { return View("Edit"); } 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 }; return View("Edit", costViewModel); } }
public ActionResult Save(AdminCostViewModel costViewModel) { costViewModel = ReplaceAllCost(costViewModel); bool dontUpdate = false; float flo; try { flo = Convert.ToSingle(costViewModel.AdditionalScreenCosts, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Additional Screen Costs\"")); dontUpdate = true; } try { flo = Convert.ToSingle(costViewModel.DTGPrintPrice, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"DTG print price\"")); dontUpdate = true; } try { flo = Convert.ToSingle(costViewModel.FirstScreenCost, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"1st Screen Cost\"")); dontUpdate = true; } try { flo = Convert.ToSingle(costViewModel.InkCost, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Ink Cost\"")); dontUpdate = true; } try { flo = Convert.ToSingle(costViewModel.LabourCost, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Labour Cost\"")); dontUpdate = true; } if (costViewModel.LabourTimePerColourPerPrint == 0) { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Labour time per colour per print\"")); dontUpdate = true; } if (costViewModel.LabourTimePerSidePrintedPerPrint == 0) { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Labour time per side printed per print\"")); dontUpdate = true; } try { flo = Convert.ToSingle(costViewModel.PercentageMarkUpRequired, new CultureInfo("en-US")); } catch { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Percentage Mark-Up required\"")); dontUpdate = true; } if (costViewModel.PrintsPerLitre == 0) { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("Incorrect entries in the box \"Prints per litre\"")); dontUpdate = true; } if (dontUpdate) { return this.RedirectToAction("Edit"); } TShirtCostRecord cost = _costService.GetCost(cultureSearch); if (cost == null) { TShirtCostRecord newCost = new TShirtCostRecord { AdditionalScreenCosts = Convert.ToSingle(costViewModel.AdditionalScreenCosts, new CultureInfo("en-US")), DTGPrintPrice = Convert.ToSingle(costViewModel.DTGPrintPrice, new CultureInfo("en-US")), FirstScreenCost = Convert.ToSingle(costViewModel.FirstScreenCost, new CultureInfo("en-US")), InkCost = Convert.ToSingle(costViewModel.InkCost, new CultureInfo("en-US")), LabourCost = Convert.ToSingle(costViewModel.LabourCost, new CultureInfo("en-US")), LabourTimePerColourPerPrint = costViewModel.LabourTimePerColourPerPrint, LabourTimePerSidePrintedPerPrint = costViewModel.LabourTimePerSidePrintedPerPrint, PercentageMarkUpRequired = Convert.ToSingle(costViewModel.PercentageMarkUpRequired, new CultureInfo("en-US")), PrintsPerLitre = costViewModel.PrintsPerLitre, SalesGoal = costViewModel.SalesGoal, MaxColors = costViewModel.MaxColors, CostCulture = cultureSearch }; if (_costService.InsertCost(newCost)) { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Information, T("Data update was successfully")); } else { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("When you try to update the data error occurred. Please, try again later!")); } } else { cost.AdditionalScreenCosts = Convert.ToSingle(costViewModel.AdditionalScreenCosts, new CultureInfo("en-US")); cost.DTGPrintPrice = Convert.ToSingle(costViewModel.DTGPrintPrice, new CultureInfo("en-US")); cost.FirstScreenCost = Convert.ToSingle(costViewModel.FirstScreenCost, new CultureInfo("en-US")); cost.InkCost = Convert.ToSingle(costViewModel.InkCost, new CultureInfo("en-US")); cost.LabourCost = Convert.ToSingle(costViewModel.LabourCost, new CultureInfo("en-US")); cost.LabourTimePerColourPerPrint = costViewModel.LabourTimePerColourPerPrint; cost.LabourTimePerSidePrintedPerPrint = costViewModel.LabourTimePerSidePrintedPerPrint; cost.PercentageMarkUpRequired = Convert.ToSingle(costViewModel.PercentageMarkUpRequired, new CultureInfo("en-US")); cost.PrintsPerLitre = costViewModel.PrintsPerLitre; cost.SalesGoal = costViewModel.SalesGoal; cost.MaxColors = costViewModel.MaxColors; if (_costService.UpdateCost(cost)) { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Information, T("Data update was successfully")); } else { Services.Notifier.Add(Orchard.UI.Notify.NotifyType.Error, T("When you try to update the data error occurred. Please, try again later!")); } } return this.RedirectToAction("Index"); }
public AdminCostViewModel ReplaceAllCost(AdminCostViewModel cost) { cost.AdditionalScreenCosts = cost.AdditionalScreenCosts.Replace(",", "."); cost.DTGPrintPrice = cost.DTGPrintPrice.Replace(",", "."); cost.FirstScreenCost = cost.FirstScreenCost.Replace(",", "."); cost.InkCost = cost.InkCost.Replace(",", "."); cost.LabourCost = cost.LabourCost.Replace(",", "."); cost.PercentageMarkUpRequired = cost.PercentageMarkUpRequired.Replace(",", "."); return cost; }
// GET: Wizard public ActionResult Index(int? id) { var commonSettings = _commonSettingsRepository.Table.Where(s=> s.CommonCulture == cultureUsed).FirstOrDefault(); if (commonSettings == null) { _commonSettingsRepository.Create(new CommonSettingsRecord() { DoNotAcceptAnyNewCampaigns = false, CommonCulture = cultureUsed }); commonSettings = _commonSettingsRepository.Table.Where(s => s.CommonCulture == cultureUsed).First(); } 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 currencys = _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 == null || product.Count() == 0) || (group == null || group.Count() == 0) || (color == null || color.Count() == 0) || (font == null || font.Count() == 0) || (swatch == null || swatch.Count() == 0) || (currencys == null || currencys.Count() == 0) || (sizes == null || sizes.Count() == 0)) { return RedirectToAction("Oops"); } var cost = _costService.GetCost(cultureUsed); AdminCostViewModel costViewModel = new AdminCostViewModel(); if (cost != null) { costViewModel.AdditionalScreenCosts = cost.AdditionalScreenCosts.ToString(); costViewModel.DTGPrintPrice = cost.DTGPrintPrice.ToString(); costViewModel.FirstScreenCost = cost.FirstScreenCost.ToString(); costViewModel.InkCost = cost.InkCost.ToString(); costViewModel.LabourCost = cost.LabourCost.ToString(); costViewModel.LabourTimePerColourPerPrint = cost.LabourTimePerColourPerPrint; costViewModel.LabourTimePerSidePrintedPerPrint = cost.LabourTimePerSidePrintedPerPrint; costViewModel.PercentageMarkUpRequired = cost.PercentageMarkUpRequired.ToString(); costViewModel.PrintsPerLitre = cost.PrintsPerLitre; costViewModel.SalesGoal = cost.SalesGoal; costViewModel.MaxColors = cost.MaxColors; costViewModel = ReplaceAllCost(costViewModel); } if (id != null && id > 0) { int 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"; var currency = _currencyRepository.Table.Where(c => c.CurrencyCulture == cultureUsed).First(); costViewModel.CurrencyCulture = currency.Code; return View(costViewModel); }