public async Task <IActionResult> Edit(int id, [Bind("OfferProductID,OfferName,ProductID")] OfferProduct offerProduct) { if (id != offerProduct.OfferProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(offerProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfferProductExists(offerProduct.OfferProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OfferName"] = new SelectList(_context.Offer, "OfferName", "OfferName", offerProduct.OfferName); ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductID", offerProduct.ProductID); return(View(offerProduct)); }
public List <OfferProduct> getProductsForOffer(string offerID, string OType) { List <OfferProduct> prodModel = new List <OfferProduct>(); try { string Sql = string.Empty; string InvConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["InventoryServices"].ConnectionString; SqlConnection SC = new SqlConnection(InvConnectionString); SqlCommand cmd = new SqlCommand(); if (!string.IsNullOrEmpty(offerID)) { if (OType == "1") { Sql = "Select * from VisionOfferProducts where OfferId in (" + offerID + ")"; } else { Sql += "Select A.OfferID,A.ProdID,A.ActiveStatus,A.Qty,A.FreeQty,ISNULL(A.OfferMRP,0) OfferMRP,ProductName ProdName,IsBuyProduct from M_OfferProducts A With(Nolock) INNER JOIN M_ProductMaster B With(Nolock) On A.ProdID=B.ProdID where A.OfferId in ( " + offerID + ")"; } cmd.CommandText = Sql; cmd.Connection = SC; SC.Close(); SC.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { OfferProduct tempobj = new OfferProduct(); tempobj.AID = reader["OfferID"] != null?Convert.ToDecimal(reader["OfferID"]) : 0; tempobj.ProductCode = reader["ProdID"] != null ? reader["ProdID"].ToString() : ""; tempobj.ProductName = reader["ProdName"] != null ? reader["ProdName"].ToString() : ""; tempobj.Qty = reader["Qty"] != null?Convert.ToDecimal(reader["Qty"]) : 0; tempobj.Confirm = ""; tempobj.Discount = 0; tempobj.Rate = 0; tempobj.PV = 0; tempobj.PVValue = 0; tempobj.freeQty = 0; tempobj.ProductType = ((reader["IsBuyProduct"] != null ? Convert.ToString(reader["IsBuyProduct"]) : "") == "Y") ? "P" : "F"; tempobj.Amount = (OType == "1" ? 0 : Convert.ToDecimal(reader["OfferMRP"])); prodModel.Add(tempobj); } } } } catch (Exception) { throw; } return(prodModel); }
private void PopulateControls() { if (offer == null) { return; } if (!offer.IsVisible) { lnkAddToCart.Visible = false; if (!UserCanEditModule(moduleId)) { return; } } heading.Text = Server.HtmlEncode(offer.Name); litOfferDescription.Text = offer.Description; lblPrice.Text = offerPrice.ToString("c", currencyCulture); lnkAddToCart.NavigateUrl = SiteRoot + "/WebStore/CartAdd.aspx?offer=" + offer.Guid.ToString() + "&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); // if there is just one product in the offer only show the product description, not thhe offer description offerHasMoreThanOneProduct = (OfferProduct.GetCountByOffer(offer.Guid) > 1); //divOfferDescription.Visible = offerHasMoreThanOneProduct; MetaDescription = offer.MetaDescription; MetaKeywordCsv = offer.MetaKeywords; AdditionalMetaMarkup = offer.CompiledMeta; using (IDataReader reader = OfferProduct.GetReaderByOffer(offer.Guid)) { rptProducts.DataSource = reader; rptProducts.DataBind(); } if (hasMedia) { if (displaySettings.UsejPlayerForMediaTeasers) { ScriptConfig.IncludejPlayer = true; jPlayerPanel.RenderPlayer = true; } else { ScriptConfig.IncludeYahooMediaPlayer = true; } } }
public List <OfferProduct> getProductsForOffer(string offerID) { List <OfferProduct> prodModel = new List <OfferProduct>(); try { string Sql = string.Empty; string InvConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["InventoryServices"].ConnectionString; SqlConnection SC = new SqlConnection(InvConnectionString); SqlCommand cmd = new SqlCommand(); if (!string.IsNullOrEmpty(offerID)) { Sql = "Exec GetFreeProducts '" + offerID + "'"; cmd.CommandText = Sql; cmd.Connection = SC; SC.Close(); SC.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { OfferProduct tempobj = new OfferProduct(); tempobj.ProductCode = reader["ProdID"] != null ? reader["ProdID"].ToString() : ""; tempobj.ProductName = reader["ProdName"] != null ? reader["ProdName"].ToString() : ""; tempobj.Qty = reader["Qty"] != null?Convert.ToDecimal(reader["Qty"]) : 0; tempobj.Confirm = reader["IsConfirm"] != null ? reader["IsConfirm"].ToString() : ""; tempobj.Discount = reader["Discount"] != null?Convert.ToDecimal(reader["Discount"]) : 0; tempobj.Rate = reader["Rate"] != null?Convert.ToDecimal(reader["Rate"]) : 0; tempobj.PV = reader["BV"] != null?Convert.ToDecimal(reader["BV"].ToString()) : 0; tempobj.PVValue = reader["BVValue"] != null?Convert.ToDecimal(reader["BVValue"]) : 0; tempobj.freeQty = reader["FreeQty"] != null?Convert.ToDecimal(reader["FreeQty"]) : 0; tempobj.ProductType = reader["ProdType"] != null ? reader["ProdType"].ToString() : ""; tempobj.Amount = reader["Amount"] != null?Convert.ToDecimal(reader["Amount"].ToString()) : 0; prodModel.Add(tempobj); } } } } catch (Exception) { throw; } return(prodModel); }
private void CreateOfferProduct() { _offerProduct = new OfferProduct(); //_offerProduct.OfferID = OfferNumber; _offerProduct.ProductID = SelectedElement.ID; _offerProduct.ProductName = SelectedElement.Name; _offerProduct.Dimension = SelectedElement.Dimenzion; _offerProduct.Price = SelectedElement.Price; _offerProduct.Description = Description; _offerProduct.Image = Image; _offerProduct.Quantity = Number; }
public async Task <IActionResult> Create([Bind("OfferProductID,OfferName,ProductID")] OfferProduct offerProduct) { if (ModelState.IsValid) { _context.Add(offerProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OfferName"] = new SelectList(_context.Offer, "OfferName", "OfferName", offerProduct.OfferName); ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductID", offerProduct.ProductID); return(View(offerProduct)); }
public ActionResult SaveOffer(Offer ObjOffer) { if (ObjOffer != null) { ObjOffer.objProductList = new List <OfferProduct>(); if (!string.IsNullOrEmpty(ObjOffer.ProductString)) { var objects = JArray.Parse(ObjOffer.ProductString); // parse as array foreach (JObject root in objects) { OfferProduct objTemp = new OfferProduct(); foreach (KeyValuePair <String, JToken> app in root) { if (app.Key == "ProdCode") { objTemp.ProductCode = app.Value.ToString(); } else if (app.Key == "ProductName") { objTemp.ProductName = app.Value.ToString(); } else if (app.Key == "FreeQty") { objTemp.Qty = (decimal)app.Value; } else if (app.Key == "BVApplied") { objTemp.IsBvApplied = app.Value.ToString(); } else if (app.Key == "OnMRP") { objTemp.OnMRP = app.Value.ToString(); } else if (app.Key == "IsBuyProduct") { objTemp.IsParent = false; } else if (app.Key == "PVVal") { objTemp.PVValue = (decimal?)app.Value; } else if (app.Key == "PVPer") { objTemp.PVPer = (decimal?)app.Value; } else if (app.Key == "Discount") { objTemp.Discount = (decimal?)app.Value; ///Convert.ToDecimal( (string) app.Value ); } else if (app.Key == "DiscountPer") { objTemp.DiscountPer = (decimal?)app.Value; } else if (app.Key == "Scheme") { objTemp.Scheme = (string)app.Value; } else if (app.Key == "Rupee") { objTemp.Rupee = (decimal?)app.Value; } else if (app.Key == "Confirm") { objTemp.Confirm = (string)app.Value; } } ObjOffer.objProductList.Add(objTemp); } } if (!string.IsNullOrEmpty(ObjOffer.ParentProductString)) { var objects = JArray.Parse(ObjOffer.ParentProductString); // parse as array foreach (JObject root in objects) { OfferProduct objTemp = new OfferProduct(); foreach (KeyValuePair <String, JToken> app in root) { if (app.Key == "ProdCode") { objTemp.ProductCode = app.Value.ToString(); } else if (app.Key == "ProductName") { objTemp.ProductName = app.Value.ToString(); } else if (app.Key == "FreeQty") { objTemp.Qty = (decimal)app.Value; } else if (app.Key == "OnMRP") { objTemp.OnMRP = app.Value.ToString(); } else if (app.Key == "IsBuyProduct") { objTemp.IsParent = true; } else if (app.Key == "IEProduct") { var t = app.Value.ToString(); if (t == "Include") { objTemp.IncludeInOffer = true; } else { objTemp.IncludeInOffer = false; } } } ObjOffer.objProductList.Add(objTemp); } } } var detail = objOfferManager.SaveOffer(ObjOffer); if (detail.ResponseStatus == "OK") { //Added log string hostName = Dns.GetHostName(); string myIP = Dns.GetHostEntry(hostName).AddressList[0].ToString(); string currentDate = DateTime.Now.ToString("yyyyMMddHHmmssfff"); objLogManager.SaveLog(Session["LoginUser"] as User, ObjOffer.ActionName + "Offer" + ObjOffer.OfferName, myIP + currentDate); } return(Json(detail, JsonRequestBehavior.AllowGet)); }
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 }