public ActionResult NewStorefront() { var user = _wca.GetContext().CurrentUser; var teeyootUser = user.ContentItem.Get(typeof(TeeyootUserPart)); var culture = _workContextAccessor.GetContext().CurrentCulture.Trim(); var cultureUsed = culture == "en-SG" ? "en-SG" : (culture == "id-ID" ? "id-ID" : "en-MY"); var campaigns = _campaignService.GetCampaignsOfUser(teeyootUser.Id).Where(c => c.IsApproved && c.CampaignCulture == cultureUsed).ToList(); var model = new StoreViewModel(); model.Campaigns = campaigns; return View(model); }
public ActionResult ViewStorefront(string url) { var culture = _wca.GetContext().CurrentCulture.Trim(); var cultureUsed = culture == "en-SG" ? "en-SG" : (culture == "id-ID" ? "id-ID" : "en-MY"); var storeFront = _storeService.GetStoreByUrl(url); if (storeFront.Campaigns[0].CampaignRecord.CampaignCulture != cultureUsed) { _cookieCultureService.SetCulture(storeFront.Campaigns[0].CampaignRecord.CampaignCulture); return RedirectToAction("ViewStorefront", new { url = url }); } var campaigns = _campaignService.GetCampaignsOfUser(int.Parse(storeFront.TeeyootUserId.ToString())).Where(c => c.IsApproved).ToList(); var model = new StoreViewModel(); model.Campaigns = campaigns; var destFolder = Path.Combine(Server.MapPath("/Media/Storefronts/"), storeFront.TeeyootUserId.ToString(), storeFront.Id.ToString()); DirectoryInfo dir = new DirectoryInfo(destFolder); if (dir.Exists == true) { foreach (FileInfo fi in dir.GetFiles()) { model.Img = "/Media/Storefronts/" + storeFront.TeeyootUserId.ToString() + "/" + storeFront.Id.ToString() + "/" + fi.Name; } } if (model.Img == null) { model.Img = "/Media/Default/images/storefront.png"; } model.Title = storeFront.Title; model.Description = storeFront.Description; IList<CampaignRecord> selectedCamp = new List<CampaignRecord>(); foreach (var camp in storeFront.Campaigns) { selectedCamp.Add(camp.CampaignRecord); } model.SelectedCampaigns = selectedCamp; model.CrossSelling = storeFront.CrossSelling; model.HideStore = storeFront.HideStore; model.Url = storeFront.Url; model.Id = storeFront.Id; var user = _wca.GetContext().CurrentUser; if (user != null) { var teeyootUser = user.ContentItem.Get(typeof(TeeyootUserPart)); if (teeyootUser.Id == storeFront.TeeyootUserId) { return View(model); } else { if (!storeFront.HideStore) { return View("StorefrontForClient", model); } else { return View("NotFound", Request.UrlReferrer != null ? Request.UrlReferrer.PathAndQuery : ""); } } } else { if (!storeFront.HideStore) { return View("StorefrontForClient", model); } else { return View("NotFound", Request.UrlReferrer != null ? Request.UrlReferrer.PathAndQuery : ""); } } }