private void AddToCart() { if (offerGuid != Guid.Empty) { Offer offer = new Offer(offerGuid); //int quantity = 1; qtyOrdered = WebUtils.ParseInt32FromQueryString("qty", qtyOrdered); if (!offer.IsAvailable) { WebUtils.SetupRedirect(this, Page.ResolveUrl( "~/WebStore/OfferDetail.aspx?pageid=" + pageId.ToString() + "&mid=" + moduleId.ToString() + "&offer=" + offerGuid.ToString())); return; } if ( (offer.Guid == offerGuid) &&(offer.StoreGuid == store.Guid) &&(store.Guid != Guid.Empty) ) { //Cart cart = StoreHelper.GetCart(store.Guid); Cart cart = StoreHelper.GetCart(); if (cart != null) { if (cart.AddOfferToCart(offer, qtyOrdered)) { // redirect to cart page WebUtils.SetupRedirect(this, SiteRoot + "/WebStore/Cart.aspx?pageid=" + pageId.ToString() + "&mid=" + moduleId.ToString() + "&cart=" + cart.CartGuid.ToString()); return; } } } } }
void grdMetaLinks_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (offerGuid == Guid.Empty) { return; } if (store == null) { return; } Offer offer = new Offer(offerGuid); if (offer.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); TextBox txtRel = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtRel"); TextBox txtHref = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtHref"); TextBox txtHrefLang = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtHrefLang"); ContentMetaLink meta = null; if (guid != Guid.Empty) { meta = metaRepository.FetchLink(guid); } else { meta = new ContentMetaLink(); if (siteUser != null) { meta.CreatedBy = siteUser.UserGuid; } meta.SortRank = metaRepository.GetNextLinkSortRank(offer.Guid); meta.ModuleGuid = store.ModuleGuid; } if (meta != null) { meta.SiteGuid = siteSettings.SiteGuid; meta.ContentGuid = offer.Guid; meta.Rel = txtRel.Text; meta.Href = txtHref.Text; meta.HrefLang = txtHrefLang.Text; if (siteUser != null) { meta.LastModBy = siteUser.UserGuid; } metaRepository.Save(meta); offer.CompiledMeta = metaRepository.GetMetaString(offer.Guid); offer.Save(); } grid.EditIndex = -1; grdMetaLinks.Columns[2].Visible = true; BindMetaLinks(); updMetaLinks.Update(); }
void grdMetaLinks_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (offerGuid == Guid.Empty) { return; } if (store == null) { return; } Offer offer = new Offer(offerGuid); if (offer.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); metaRepository.DeleteLink(guid); offer.CompiledMeta = metaRepository.GetMetaString(offer.Guid); offer.Save(); grid.Columns[2].Visible = true; BindMetaLinks(); updMetaLinks.Update(); }
void grdMetaLinks_RowCommand(object sender, GridViewCommandEventArgs e) { if (offerGuid == Guid.Empty) { return; } if (store == null) { return; } Offer offer = new Offer(offerGuid); if (offer.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; string sGuid = e.CommandArgument.ToString(); if (sGuid.Length != 36) { return; } Guid guid = new Guid(sGuid); ContentMetaLink meta = metaRepository.FetchLink(guid); if (meta == null) { return; } switch (e.CommandName) { case "MoveUp": meta.SortRank -= 3; break; case "MoveDown": meta.SortRank += 3; break; } metaRepository.Save(meta); List<ContentMetaLink> metaList = metaRepository.FetchLinksByContent(offer.Guid); metaRepository.ResortMeta(metaList); offer.CompiledMeta = metaRepository.GetMetaString(offer.Guid); offer.Save(); BindMetaLinks(); updMetaLinks.Update(); }
void grdContentMeta_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (offerGuid == Guid.Empty) { return; } if (store == null) { return; } Offer offer = new Offer(offerGuid); if (offer.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); TextBox txtName = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtName"); TextBox txtScheme = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtScheme"); TextBox txtLangCode = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtLangCode"); DropDownList ddDirection = (DropDownList)grid.Rows[e.RowIndex].Cells[1].FindControl("ddDirection"); TextBox txtMetaContent = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtMetaContent"); ContentMeta meta = null; if (guid != Guid.Empty) { meta = metaRepository.Fetch(guid); } else { meta = new ContentMeta(); if (siteUser != null) { meta.CreatedBy = siteUser.UserGuid; } meta.SortRank = metaRepository.GetNextSortRank(offer.Guid); meta.ModuleGuid = store.ModuleGuid; } if (meta != null) { meta.SiteGuid = siteSettings.SiteGuid; meta.ContentGuid = offer.Guid; meta.Dir = ddDirection.SelectedValue; meta.LangCode = txtLangCode.Text; meta.MetaContent = txtMetaContent.Text; meta.Name = txtName.Text; meta.Scheme = txtScheme.Text; if (siteUser != null) { meta.LastModBy = siteUser.UserGuid; } metaRepository.Save(meta); offer.CompiledMeta = metaRepository.GetMetaString(offer.Guid); offer.Save(); } grid.EditIndex = -1; grdContentMeta.Columns[2].Visible = true; BindMeta(); upMeta.Update(); }
private void btnDelete_Click(object sender, EventArgs e) { if (offerGuid != Guid.Empty) { if (config.IndexOffersInSearch) { Offer offer = new Offer(offerGuid); if (WebConfigSettings.LogIpAddressForContentDeletions) { log.Info("user deleted offer " + offer.Name + " from ip address " + SiteUtils.GetIP4Address()); } ContentChangedEventArgs args = new ContentChangedEventArgs(); args.IsDeleted = true; offer_ContentChanged(offer, args); } FriendlyUrl.DeleteByPageGuid(offerGuid); Offer.Delete( offerGuid, siteUser.UserGuid, SiteUtils.GetIP4Address()); SiteUtils.QueueIndexing(); WebUtils.SetupRedirect(this, GetReturnUrl()); } }
private void BindMetaLinks() { if (offerGuid == Guid.Empty) { return; } if (store == null) { return; } Offer offer = new Offer(offerGuid); if (offer.StoreGuid != store.Guid) { return; } List<ContentMetaLink> meta = metaRepository.FetchLinksByContent(offer.Guid); grdMetaLinks.DataSource = meta; grdMetaLinks.DataBind(); btnAddMetaLink.Visible = true; }
private static void IndexItem(Offer offer) { if (WebConfigSettings.DisableSearchIndex) { return; } if (offer == null) { if (log.IsErrorEnabled) { log.Error("product object passed to OfferSearchIndexBuilder.IndexItem was null"); } return; } Store store = new Store(offer.StoreGuid); Module module = new Module(store.ModuleId); Guid webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593"); ModuleDefinition webStoreFeature = new ModuleDefinition(webStoreFeatureGuid); //// get list of pages where this module is published List<PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( offer.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); if (offer.SearchIndexPath.Length > 0) { indexItem.IndexPath = offer.SearchIndexPath; } indexItem.SiteId = offer.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; if (offer.Url.Length > 0) { indexItem.ViewPage = offer.Url.Replace("~/", string.Empty); indexItem.UseQueryStringParams = false; } else { indexItem.ViewPage = "/WebStore/OfferDetail.aspx"; } indexItem.ItemKey = offer.Guid.ToString(); indexItem.ModuleId = store.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.Title = offer.Name; indexItem.PageMetaDescription = offer.MetaDescription; indexItem.PageMetaKeywords = offer.MetaKeywords; indexItem.CreatedUtc = offer.Created; indexItem.LastModUtc = offer.LastModified; indexItem.Content = offer.Teaser + " " + offer.Description.Replace(tabScript, string.Empty) + " " + offer.MetaDescription + " " + offer.MetaKeywords; indexItem.FeatureId = webStoreFeatureGuid.ToString(); indexItem.FeatureName = webStoreFeature.FeatureName; indexItem.FeatureResourceFile = webStoreFeature.ResourceFile; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); } if (debugLog) log.Debug("Indexed " + offer.Name); }
private void PopulateOfferControls() { if (store == null) { return; } if (offerGuid != Guid.Empty) { Offer offer = new Offer(offerGuid); Title = SiteUtils.FormatPageTitle(siteSettings, WebStoreResources.OfferEditHeading + " - " + offer.Name); txtName.Text = offer.Name; txtProductListName.Text = offer.ProductListName; txtPrice.Text = offer.Price.ToString("c", currencyCulture); edAbstract.Text = offer.Teaser; edDescription.Text = offer.Description; txtSortRank1.Text = offer.SortRank1.ToInvariantString(); txtSortRank2.Text = offer.SortRank2.ToInvariantString(); txtMetaDescription.Text = offer.MetaDescription; txtMetaKeywords.Text = offer.MetaKeywords; ListItem listItem = ddTaxClassGuid.Items.FindByValue(offer.TaxClassGuid.ToString()); if (listItem != null) { ddTaxClassGuid.ClearSelection(); listItem.Selected = true; } chkIsVisible.Checked = offer.IsVisible; chkIsSpecial.Checked = offer.IsSpecial; chkIsDonation.Checked = offer.IsDonation; chkShowDetailLink.Checked = offer.ShowDetailLink; } }
public void InstallContent(Module module, string configInfo) { if (string.IsNullOrEmpty(configInfo)) { return; } Store store = new Store(module.SiteGuid, module.ModuleId); if (store.Guid == Guid.Empty) // No store created yet { store = new Store(); store.SiteGuid = module.SiteGuid; store.ModuleId = module.ModuleId; store.Save(); } SiteSettings siteSettings = new SiteSettings(module.SiteId); Guid taxClassGuid = Guid.Empty; List<TaxClass> taxClasses = TaxClass.GetList(siteSettings.SiteGuid); if (taxClasses.Count == 0) { TaxClass taxClass = new TaxClass(); taxClass.SiteGuid = siteSettings.SiteGuid; taxClass.Title = "Taxable"; taxClass.Description = "Taxable"; taxClass.Save(); taxClass = new TaxClass(); taxClass.SiteGuid = siteSettings.SiteGuid; taxClass.Title = "Not Taxable"; taxClass.Description = "Not Taxable"; taxClass.Save(); taxClassGuid = taxClass.Guid; } else { foreach (TaxClass t in taxClasses) { if (t.Title == "Not Taxable") { taxClassGuid = t.Guid; } } } SiteUser admin = SiteUser.GetNewestUser(siteSettings); XmlDocument xml = new XmlDocument(); using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo))) { xml.LoadXml(stream.ReadToEnd()); } CultureInfo currencyCulture = new CultureInfo("en-US"); if (xml.DocumentElement.Name == "store") { // update the store XmlAttributeCollection storeAttrributes = xml.DocumentElement.Attributes; if (storeAttrributes["storeName"] != null) { store.Name = storeAttrributes["storeName"].Value; } if (storeAttrributes["emailFrom"] != null) { store.EmailFrom = storeAttrributes["emailFrom"].Value; } if (storeAttrributes["currencyCulture"] != null) { currencyCulture = new CultureInfo(storeAttrributes["currencyCulture"].Value); } if (storeAttrributes["ownerName"] != null) { store.OwnerName = storeAttrributes["ownerName"].Value; } if (storeAttrributes["ownerEmail"] != null) { store.OwnerEmail = storeAttrributes["ownerEmail"].Value; } if (storeAttrributes["city"] != null) { store.City = storeAttrributes["city"].Value; } if (storeAttrributes["postalCode"] != null) { store.PostalCode = storeAttrributes["postalCode"].Value; } if (storeAttrributes["phone"] != null) { store.Phone = storeAttrributes["phone"].Value; } if (storeAttrributes["address"] != null) { store.Address = storeAttrributes["address"].Value; } if (storeAttrributes["countryGuid"] != null) { string g = storeAttrributes["countryGuid"].Value; if(g.Length == 36) { Guid countryGuid = new Guid(g); store.CountryGuid = countryGuid; } } if (storeAttrributes["stateGuid"] != null) { string s = storeAttrributes["stateGuid"].Value; if(s.Length == 36) { Guid stateGuid = new Guid(s); store.ZoneGuid = stateGuid; } } foreach (XmlNode descriptionNode in xml.DocumentElement.ChildNodes) { if (descriptionNode.Name == "storeDescription") { store.Description = descriptionNode.InnerText; break; } } store.Save(); //module settings foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "moduleSetting") { XmlAttributeCollection settingAttributes = node.Attributes; if ((settingAttributes["settingKey"] != null) && (settingAttributes["settingKey"].Value.Length > 0)) { string key = settingAttributes["settingKey"].Value; string val = string.Empty; if (settingAttributes["settingValue"] != null) { val = settingAttributes["settingValue"].Value; } ModuleSettings.UpdateModuleSetting(module.ModuleGuid, module.ModuleId, key, val); } } } if (storeAttrributes["productFilesPath"] != null) { if (storeAttrributes["productFilesPath"].Value.Length > 0) { string destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/webstoreproductfiles/"; if (!Directory.Exists(HostingEnvironment.MapPath(destPath))) { Directory.CreateDirectory(HostingEnvironment.MapPath(destPath)); } IOHelper.CopyFolderContents(HostingEnvironment.MapPath(storeAttrributes["productFilesPath"].Value), HostingEnvironment.MapPath(destPath)); } } if (storeAttrributes["teaserFilesPath"] != null) { if (storeAttrributes["teaserFilesPath"].Value.Length > 0) { string destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/webstoreproductpreviewfiles/"; if (!Directory.Exists(HostingEnvironment.MapPath(destPath))) { Directory.CreateDirectory(HostingEnvironment.MapPath(destPath)); } IOHelper.CopyFolderContents(HostingEnvironment.MapPath(storeAttrributes["teaserFilesPath"].Value), HostingEnvironment.MapPath(destPath)); } } FullfillDownloadTerms term = new FullfillDownloadTerms(); term.Name = WebStoreResources.DownloadUnlimited; term.Description = WebStoreResources.DownloadUnlimited; if (admin != null) { term.CreatedBy = admin.UserGuid; } term.StoreGuid = store.Guid; term.Save(); XmlNode offersNode = null; foreach (XmlNode n in xml.DocumentElement.ChildNodes) { if (n.Name == "offers") { offersNode = n; break; } } if (offersNode != null) { foreach (XmlNode node in offersNode.ChildNodes) { if (node.Name == "offer") { XmlAttributeCollection offerAttrributes = node.Attributes; Offer offer = new Offer(); offer.StoreGuid = store.Guid; offer.Created = DateTime.UtcNow; offer.LastModified = DateTime.UtcNow; if (admin != null) { offer.CreatedBy = admin.UserGuid; offer.LastModifiedBy = admin.UserGuid; } if (offerAttrributes["offerName"] != null) { offer.Name = offerAttrributes["offerName"].Value; } if (offerAttrributes["nameOnProductList"] != null) { offer.ProductListName = offerAttrributes["nameOnProductList"].Value; } if ( (offerAttrributes["isVisible"] != null) && (offerAttrributes["isVisible"].Value.ToLower() == "true") ) { offer.IsVisible = true; } if ( (offerAttrributes["isSpecial"] != null) && (offerAttrributes["isSpecial"].Value.ToLower() == "true") ) { offer.IsSpecial = true; } //offer.IsDonation = chkIsDonation.Checked; if ( (offerAttrributes["showOfferDetailLink"] != null) && (offerAttrributes["showOfferDetailLink"].Value.ToLower() == "true") ) { offer.ShowDetailLink = true; } if (offerAttrributes["primarySort"] != null) { int sort = 5000; if (int.TryParse(offerAttrributes["primarySort"].Value, out sort)) { offer.SortRank1 = sort; } } if (offerAttrributes["secondarySort"] != null) { int sort = 5000; if (int.TryParse(offerAttrributes["secondarySort"].Value, out sort)) { offer.SortRank2 = sort; } } if (offerAttrributes["price"] != null) { offer.Price = decimal.Parse(offerAttrributes["price"].Value, NumberStyles.Currency, currencyCulture); } offer.TaxClassGuid = taxClassGuid; offer.Url = "/" + SiteUtils.SuggestFriendlyUrl( offer.Name + WebStoreResources.OfferUrlSuffix, siteSettings); foreach (XmlNode descriptionNode in node.ChildNodes) { if (descriptionNode.Name == "abstract") { offer.Teaser = descriptionNode.InnerText; break; } } foreach (XmlNode descriptionNode in node.ChildNodes) { if (descriptionNode.Name == "description") { offer.Description = descriptionNode.InnerText; break; } } if (offer.Save()) { FriendlyUrl newUrl = new FriendlyUrl(); newUrl.SiteId = siteSettings.SiteId; newUrl.SiteGuid = siteSettings.SiteGuid; newUrl.PageGuid = offer.Guid; newUrl.Url = offer.Url.Replace("/", string.Empty); newUrl.RealUrl = "~/WebStore/OfferDetail.aspx?pageid=" + module.PageId.ToInvariantString() + "&mid=" + module.ModuleId.ToInvariantString() + "&offer=" + offer.Guid.ToString(); newUrl.Save(); } foreach (XmlNode productNode in node.ChildNodes) { if (productNode.Name == "product") { XmlAttributeCollection productAttrributes = productNode.Attributes; Product product = new Product(); product.StoreGuid = store.Guid; if (admin != null) { product.CreatedBy = admin.UserGuid; } product.Created = DateTime.UtcNow; product.TaxClassGuid = taxClassGuid; if (productAttrributes["name"] != null) { product.Name = productAttrributes["name"].Value; } if (productAttrributes["modelNumber"] != null) { product.ModelNumber = productAttrributes["modelNumber"].Value; } if (productAttrributes["teaser"] != null) { product.TeaserFile = productAttrributes["teaser"].Value; } if (productAttrributes["fulfillmentType"] != null) { product.FulfillmentType = Product.FulfillmentTypeFromString(productAttrributes["fulfillmentType"].Value); } product.Status = ProductStatus.Available; product.Weight = 0; product.QuantityOnHand = 0; if ( (productAttrributes["showInProductList"] != null) && (productAttrributes["showInProductList"].Value.ToLower() == "true") ) { product.ShowInProductList = true; } if ( (productAttrributes["enableRating"] != null) && (productAttrributes["enableRating"].Value.ToLower() == "true") ) { product.EnableRating = true; } if (productAttrributes["primarySort"] != null) { int sort = 5000; if (int.TryParse(productAttrributes["primarySort"].Value, out sort)) { product.SortRank1 = sort; } } if (productAttrributes["secondarySort"] != null) { int sort = 5000; if (int.TryParse(productAttrributes["secondarySort"].Value, out sort)) { product.SortRank2 = sort; } } product.Url = "/" + SiteUtils.SuggestFriendlyUrl( product.Name + WebStoreResources.ProductUrlSuffix, siteSettings); foreach (XmlNode descriptionNode in productNode.ChildNodes) { if (descriptionNode.Name == "abstract") { product.Teaser = descriptionNode.InnerText; break; } } foreach (XmlNode descriptionNode in productNode.ChildNodes) { if (descriptionNode.Name == "description") { product.Description = descriptionNode.InnerText; break; } } if (product.Save()) { if (productAttrributes["file"] != null) { ProductFile productFile = new ProductFile(product.Guid); productFile.ServerFileName = productAttrributes["file"].Value; if (productAttrributes["fileName"] != null) { productFile.FileName = productAttrributes["fileName"].Value; } if (admin != null) { productFile.CreatedBy = admin.UserGuid; } productFile.Save(); } FriendlyUrl newUrl = new FriendlyUrl(); newUrl.SiteId = siteSettings.SiteId; newUrl.SiteGuid = siteSettings.SiteGuid; newUrl.PageGuid = product.Guid; newUrl.Url = product.Url.Replace("/", string.Empty); newUrl.RealUrl = "~/WebStore/ProductDetail.aspx?pageid=" + module.PageId.ToInvariantString() + "&mid=" + module.ModuleId.ToInvariantString() + "&product=" + product.Guid.ToString(); newUrl.Save(); } // create offer product OfferProduct offerProduct = new OfferProduct(); if (admin != null) { offerProduct.CreatedBy = admin.UserGuid; } offerProduct.ProductGuid = product.Guid; if (productAttrributes["fulfillmentType"] != null) { offerProduct.FullfillType = Convert.ToByte(productAttrributes["fulfillmentType"].Value); } if (productAttrributes["sortOrder"] != null) { int sort = 100; if (int.TryParse(productAttrributes["sortOrder"].Value, out sort)) { offerProduct.SortOrder = sort; } } if (productAttrributes["quantity"] != null) { int qty = 1; if (int.TryParse(productAttrributes["quantity"].Value, out qty)) { offerProduct.Quantity = qty; } } offerProduct.FullfillType = (byte)product.FulfillmentType; offerProduct.FullFillTermsGuid = term.Guid; offerProduct.OfferGuid = offer.Guid; offerProduct.Save(); } } } } } } //create product }
public bool AddOfferToCart(Offer offer, int quantity) { if (offer == null) { return false; } bool foundOfferInCart = false; bool deleted = false; foreach (CartOffer cOffer in CartOffers) { if (cOffer.OfferGuid == offer.Guid) { foundOfferInCart = true; cOffer.Quantity += quantity; if (cOffer.Quantity <= 0) { DBCartOffer.Delete(cOffer.ItemGuid); ResetCartOffers(); deleted = true; } else { cOffer.Save(); } RefreshTotals(); Save(); } } if (foundOfferInCart) { return !deleted; } if (quantity <= 0) { return false; } CartOffer cartOffer = new CartOffer(); cartOffer.CartGuid = this.cartGuid; //cartOffer.CurrencyGuid = currencyGuid; cartOffer.TaxClassGuid = offer.TaxClassGuid; cartOffer.OfferGuid = offer.Guid; cartOffer.OfferPrice = offer.Price; cartOffer.Quantity = quantity; // this will be updated later, just initialize to 0 cartOffer.Tax = 0; cartOffer.IsDonation = offer.IsDonation; cartOffer.Save(); // clear offers collection so it will be refreshed cartOffers = GetCartOffers(); //CalculateSubTotal(); //CalculatShippingTotal(); //CalculateTaxTotal(); //CalculateTotal(); //Save(); RefreshTotals(); return true; }
public bool AddOfferToCart(Offer offer, int quantity) { if (offer == null) { return(false); } bool foundOfferInCart = false; bool deleted = false; foreach (CartOffer cOffer in CartOffers) { if (cOffer.OfferGuid == offer.Guid) { foundOfferInCart = true; int newQty = cOffer.Quantity + quantity; if (offer.MaxPerOrder < newQty) { cOffer.Quantity = offer.MaxPerOrder; } else { cOffer.Quantity = newQty; } if (cOffer.Quantity <= 0) { DBCartOffer.Delete(cOffer.ItemGuid); ResetCartOffers(); deleted = true; } else { cOffer.Save(); } RefreshTotals(); Save(); } } if (foundOfferInCart) { return(!deleted); } if (quantity <= 0) { return(false); } if (offer.MaxPerOrder < quantity) { quantity = offer.MaxPerOrder; } CartOffer cartOffer = new CartOffer(); cartOffer.CartGuid = this.cartGuid; //cartOffer.CurrencyGuid = currencyGuid; cartOffer.TaxClassGuid = offer.TaxClassGuid; cartOffer.OfferGuid = offer.Guid; cartOffer.OfferPrice = offer.Price; cartOffer.Quantity = quantity; // this will be updated later, just initialize to 0 cartOffer.Tax = 0; cartOffer.IsDonation = offer.IsDonation; cartOffer.MaxPerOrder = offer.MaxPerOrder; cartOffer.Save(); // clear offers collection so it will be refreshed cartOffers = GetCartOffers(); //CalculateSubTotal(); //CalculatShippingTotal(); //CalculateTaxTotal(); //CalculateTotal(); //Save(); RefreshTotals(); return(true); }
private bool Update() { Offer offer = new Offer(this.guid); DBOffer.AddOfferHistory( Guid.NewGuid(), offer.Guid, offer.StoreGuid, offer.IsVisible, offer.IsSpecial, offer.Created, offer.CreatedBy, offer.CreatedFromIP, offer.IsDeleted, offer.DeletedTime, offer.DeletedBy, offer.DeletedFromIP, offer.LastModified, offer.LastModifiedBy, offer.LastModifiedFromIP, DateTime.UtcNow, offer.TaxClassGuid, offer.Url); bool result = DBOffer.Update( this.guid, this.isVisible, this.isSpecial, this.taxClassGuid, this.url, this.lastModified, this.lastModifiedBy, this.lastModifiedFromIP, this.isDonation, this.name, this.description, this.teaser, this.price, this.productListName, this.showDetailLink, this.userCanSetPrice, this.maxPerOrder, this.sortRank1, this.sortRank2, this.metaDescription, this.metaKeywords, this.compiledMeta); if (result) { ContentChangedEventArgs e = new ContentChangedEventArgs(); OnContentChanged(e); } return result; }
public static bool Delete( Guid guid, Guid deletedBy, string deletedFromIP) { Offer offer = new Offer(guid); DBOffer.AddOfferHistory( Guid.NewGuid(), offer.Guid, offer.StoreGuid, offer.IsVisible, offer.IsSpecial, offer.Created, offer.CreatedBy, offer.CreatedFromIP, offer.IsDeleted, offer.DeletedTime, offer.DeletedBy, offer.DeletedFromIP, offer.LastModified, offer.LastModifiedBy, offer.LastModifiedFromIP, DateTime.UtcNow, offer.TaxClassGuid, offer.Url); return DBOffer.Delete( guid, DateTime.UtcNow, deletedBy, deletedFromIP); }
protected void rptOffers_ItemCommand(object source, RepeaterCommandEventArgs e) { if ((store != null)&&(cart != null)&&(e.CommandName == "AddToCart")) { Guid offerGuid = Guid.Empty; int qtyOrdered = 1; string offerG = e.CommandArgument.ToString(); if (offerG.Length == 36) { offerGuid = new Guid(offerG); } TextBox txtQuantity = (TextBox)e.Item.FindControl("txtQuantity"); if ((txtQuantity != null) && (txtQuantity.Text.Length > 0)) { int.TryParse(txtQuantity.Text, out qtyOrdered); } if (offerGuid != Guid.Empty) { Offer offer = new Offer(offerGuid); if (offer.StoreGuid == store.Guid) { cart.AddOfferToCart(offer, qtyOrdered); } } } WebUtils.SetupRedirect(this, Request.RawUrl); }
private void Save() { if (store == null) { return; } Offer offer; if (offerGuid != Guid.Empty) { offer = new Offer(offerGuid); } else { offer = new Offer(); offer.Created = DateTime.UtcNow; offer.CreatedBy = siteUser.UserGuid; offer.CreatedFromIP = SiteUtils.GetIP4Address(); } if (config.IndexOffersInSearch) { offer.ContentChanged += new ContentChangedEventHandler(offer_ContentChanged); } offer.Name = txtName.Text; offer.ProductListName = txtProductListName.Text; offer.Teaser = edAbstract.Text; offer.Description = edDescription.Text; offer.StoreGuid = store.Guid; offer.IsVisible = chkIsVisible.Checked; offer.IsSpecial = chkIsSpecial.Checked; offer.IsDonation = chkIsDonation.Checked; offer.ShowDetailLink = chkShowDetailLink.Checked; offer.MetaDescription = txtMetaDescription.Text; offer.MetaKeywords = txtMetaKeywords.Text; // If the sort rank inputs are left null on the product // and offer creation screens, the in.Parse gets all // bent out of shape so I converted to TryParse if (int.TryParse(txtSortRank1.Text, NumberStyles.Number, CultureInfo.InvariantCulture, out intSortRank1)) { offer.SortRank1 = intSortRank1; } if (int.TryParse(txtSortRank2.Text, NumberStyles.Number, CultureInfo.InvariantCulture, out intSortRank2)) { offer.SortRank2 = intSortRank2; } offer.Price = decimal.Parse(txtPrice.Text, NumberStyles.Currency, currencyCulture); if (!String.IsNullOrEmpty(ddTaxClassGuid.SelectedValue)) { Guid taxClassGuid = new Guid(ddTaxClassGuid.SelectedValue); offer.TaxClassGuid = taxClassGuid; } offer.LastModified = DateTime.UtcNow; offer.LastModifiedBy = siteUser.UserGuid; offer.LastModifiedFromIP = SiteUtils.GetIP4Address(); bool needToCreateFriendlyUrl = false; if ((offer.Url.Length == 0) && (txtName.Text.Length > 0)) { offer.Url = "/" + SiteUtils.SuggestFriendlyUrl( txtName.Text + WebStoreResources.OfferUrlSuffix, siteSettings); needToCreateFriendlyUrl = true; } else { //TODO: change url if title changed? } if (offer.Save()) { offerGuid = offer.Guid; if (needToCreateFriendlyUrl) { FriendlyUrl newUrl = new FriendlyUrl(); newUrl.SiteId = siteSettings.SiteId; newUrl.SiteGuid = siteSettings.SiteGuid; newUrl.PageGuid = offer.Guid; newUrl.Url = offer.Url.Replace("/", string.Empty); newUrl.RealUrl = "~/WebStore/OfferDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&offer=" + offer.Guid.ToString(); newUrl.Save(); } } SiteUtils.QueueIndexing(); WebUtils.SetupRedirect(this, GetRefreshUrl()); }
private void LoadSettings() { commerceConfig = SiteUtils.GetCommerceConfig(); store = StoreHelper.GetStore(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); if((store != null)&&(offerGuid != Guid.Empty)) { offer = new Offer(offerGuid); offerPrice = offer.Price; } teaserFileBaseUrl = WebUtils.GetSiteRoot() + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/webstoreproductpreviewfiles/"; AddClassToBody("webstore webstoreofferdetail"); }
void rptOffers_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "addToCart": default: Cart cart = StoreHelper.GetCart(); if (cart == null) { return; } string strGuid = e.CommandArgument.ToString(); if (strGuid.Length != 36) { return; } Guid offerGuid = new Guid(strGuid); Offer offer = new Offer(offerGuid); int quantity = 1; TextBox txtQty = e.Item.FindControl("txtQuantity") as TextBox; if (txtQty != null) { try { int.TryParse(txtQty.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out quantity); } catch (ArgumentException) { } } if (quantity < 0) { quantity = 1; } if (cart.AddOfferToCart(offer, quantity)) { // redirect to cart page WebUtils.SetupRedirect(this, SiteRoot + "/WebStore/Cart.aspx?pageid=" + pageId.ToString() + "&mid=" + moduleId.ToString() + "&cart=" + cart.CartGuid.ToString()); return; } WebUtils.SetupRedirect(this, Request.RawUrl); break; } }