protected void lkbDeactive_Click(object sender, EventArgs e) { List <Merchant_Commision> coms = new List <Merchant_Commision>(); foreach (GridViewRow row in gvItemsCOM.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { using (Ad_ConnectionString model = new Ad_ConnectionString()) { int comID = Convert.ToInt32(gvItemsCOM.DataKeys[row.RowIndex].Value); var varlist = (from var in model.Adv_Commisions where var.CommisionID == comID select var).FirstOrDefault(); if (ddlStatus.SelectedValue.ToString() == Constants.Status.Active.ToString()) { varlist.Status = Convert.ToInt32(Constants.Status.Active); } else if (ddlStatus.SelectedValue.ToString() == Constants.Status.DeActive.ToString()) { varlist.Status = Convert.ToInt32(Constants.Status.DeActive); } model.SaveChanges(); } } } }
private void UpdateCategoryID() { try { using (var model = new Ad_ConnectionString()) { clsCommonMethods _modelCat = new clsCommonMethods(); var catList = _modelCat.GetAllCategories(); var catIDs = (from ct in catList select ct.CategoryName_V).ToList(); foreach (Category cat in catList) { if (cat.SubCategory.Count > 0) { var orginalCat = model.Adv_Product_Commons.Where(nc => nc.CategoryID_N == null && nc.ProductCategoryName != null && nc.Ad_For > 0).Where(p => p.ProductCategoryName.Equals(cat.CategoryName_V)).ToList(); // p.cat.CategoryName.Contains(cat.CategoryName_V)).ToList(); orginalCat.ForEach(aa => aa.CategoryID_N = cat.CategoryID_N); //a=>a..c.CategoryID_N=cat.CategoryID_N); model.SaveChanges(); var orginal = model.Adv_Product_Commons.Where(nc => nc.CategoryID_N == null && nc.ProductCategoryName != null && nc.Ad_For > 0).Where(p => cat.SubCategory.Select(s => s.SubCategoryName_V).ToList().Equals(p.ProductCategoryName)).ToList(); // p.cat.CategoryName.Contains(cat.CategoryName_V)).ToList(); orginal.ForEach(aa => aa.CategoryID_N = cat.CategoryID_N); //a=>a..c.CategoryID_N=cat.CategoryID_N); model.SaveChanges(); } else { var orginal = model.Adv_Product_Commons.Where(nc => nc.CategoryID_N == null && nc.ProductCategoryName != null && nc.Ad_For > 0).Where(p => p.ProductCategoryName.Equals(cat.CategoryName_V)).ToList(); // p.cat.CategoryName.Contains(cat.CategoryName_V)).ToList(); orginal.ForEach(aa => aa.CategoryID_N = cat.CategoryID_N); //a=>a..c.CategoryID_N=cat.CategoryID_N); model.SaveChanges(); if (cat.CategoryName_V == "Mobile Phones") { var cateNewMap = model.Adv_Product_Commons.Where(nc => nc.CategoryID_N == null && nc.ProductCategoryName != null && nc.Ad_For > 0).Where(p => p.ProductCategoryName.Equals("Mobiles & Accessories>Mobiles")).ToList(); // p.cat.CategoryName.Contains(cat.CategoryName_V)).ToList(); cateNewMap.ForEach(aa => aa.CategoryID_N = cat.CategoryID_N); //a=>a..c.CategoryID_N=cat.CategoryID_N); model.SaveChanges(); } } } model.Dispose(); } } catch (Exception ex) { } }
protected void lkbResolve_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvItems.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { int tid = Convert.ToInt32(gvItems.DataKeys[row.RowIndex].Value); using (Ad_ConnectionString model = new Ad_ConnectionString()) { var original = model.Adv_MissingCashbacks.Where(c => c.TicketNo == tid).SingleOrDefault(); if (original != null) { original.Status = (int)Constants.Status.Resolve; model.SaveChanges(); } } } } }
protected void Delete_Click(object sender, EventArgs e) { List <Int64> offerIds = new List <Int64>(); foreach (GridViewRow row in gvItems.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Int64 offerID = Convert.ToInt32(gvItems.DataKeys[row.RowIndex].Value); using (Ad_ConnectionString model = new Ad_ConnectionString()) { model.Adv_FeatureOffer1.Where(x => x.OfferID == offerID).ToList().ForEach(model.Adv_FeatureOffer1.DeleteObject); model.SaveChanges(); } } } getFeatureslist(); }
protected void lkbFeatureOffer_Click(object sender, EventArgs e) { List <Int64> offerIds = new List <Int64>(); foreach (GridViewRow row in gvItems.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Int64 offerID = Convert.ToInt32(gvItems.DataKeys[row.RowIndex].Value); using (Ad_ConnectionString model = new Ad_ConnectionString()) { Adv_FeatureOffer1 offer = new Adv_FeatureOffer1(); offer.OfferID = offerID; offer.OfferType = Convert.ToInt16(Convert.ToInt32((Constants.FeatureTypeOffer)Enum.Parse(typeof(Constants.FeatureTypeOffer), ddlOfferType.SelectedValue.ToString()))); model.AddToAdv_FeatureOffer1(offer); model.SaveChanges(); } } } BindOffersList(); }
protected void btnRunTemplateDesign_Click(object sender, EventArgs e) { StringBuilder templateItems = new StringBuilder(); if (ddlTemplateType.SelectedValue.ToString() == Constants.MailFormatContentType.ImageContent.ToString()) { using (Ad_ConnectionString model = new Ad_ConnectionString()) { int bannerLocation = Convert.ToInt32(Constants.BannerLocation.EmailImageMarketing); var varlist = (from var in model.Adv_Trn_Banners where var.BannerLocation == bannerLocation select var).ToList(); foreach (Adv_Trn_Banner item in varlist) { string mNamed; if (item.Adv_Mst_Merchant.MerchantNameDetail.ToString().IndexOf(".") >= 0) { mNamed = item.Adv_Mst_Merchant.MerchantNameDetail.Substring(0, item.Adv_Mst_Merchant.MerchantNameDetail.ToString().IndexOf(".")); } else { mNamed = item.Adv_Mst_Merchant.MerchantNameDetail; } templateItems.Append(ImagetemplateBuilder(item.BannerURL, mNamed, item.BannerText, item.Description)); } string body = string.Empty; using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/MailFormat/ImageTemplateMarketing.htm"))) { body = reader.ReadToEnd(); } body = body.Replace("{AddImages}", templateItems.ToString()); txtCodeGenerate.Text = body; //Update Contaent in DB -------------------------------------------------------------- Int16 mailFormatType = Convert.ToInt16(Constants.MailFormatContentType.ImageContent); var contentMail = (from pro in model.Adv_MailContents where pro.MailType == mailFormatType select pro).SingleOrDefault(); if (contentMail != null) { contentMail.MailContent = body; model.SaveChanges(); } else { Adv_MailContent mailContent = new Adv_MailContent(); mailContent.MailContent = body; mailContent.MailType = Convert.ToInt16(Constants.MailFormatContentType.ImageContent); model.AddToAdv_MailContents(mailContent); model.SaveChanges(); } } } else if (ddlTemplateType.SelectedValue.ToString() == Constants.MailFormatContentType.OfferContent.ToString()) { using (Ad_ConnectionString model = new Ad_ConnectionString()) { Int64 offTYpe = Convert.ToInt64(Constants.FeatureTypeOffer.FeatureOffer); var varlist = (from var in model.Adv_Offers where model.Adv_FeatureOffer1.Where(w => w.OfferType == offTYpe).Select(s => s.OfferID).Contains(var.OfferID) select var).ToList(); int offerCount = 1; foreach (Adv_Offer item in varlist) { string mNamed; if (item.Adv_Mst_Merchant.MerchantNameDetail.ToString().IndexOf(".") >= 0) { mNamed = item.Adv_Mst_Merchant.MerchantNameDetail.Substring(0, item.Adv_Mst_Merchant.MerchantNameDetail.ToString().IndexOf(".")); } else { mNamed = item.Adv_Mst_Merchant.MerchantNameDetail; } string comision = string.Empty; //Constants.PriceType.INR //int? priceType = 1; var com = (from c in model.Adv_Commisions where c.MerchantID == item.Adv_Mst_Merchant.MID select c).OrderByDescending(x => x.UserCommision).FirstOrDefault(); if (offerCount == 1) { templateItems.Append(OffertemplateBuilder("<tr>", "divLeft", item.Adv_Mst_Merchant.LogoUrl, mNamed, item.Title, com.UserCommision + getPiceType(com.PriceType), "")); } else if (offerCount == 2) { templateItems.Append(OffertemplateBuilder("", "divLeft", item.Adv_Mst_Merchant.LogoUrl, mNamed, item.Title, com.UserCommision + getPiceType(com.PriceType), "")); } else { templateItems.Append(OffertemplateBuilder("", "divLeft", item.Adv_Mst_Merchant.LogoUrl, mNamed, item.Title, com.UserCommision + getPiceType(com.PriceType), "</tr>")); if (offerCount == 3) { offerCount = 0; } } offerCount = offerCount + 1; } string body = string.Empty; using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/MailFormat/OfferTemplateMarketing.htm"))) { body = reader.ReadToEnd(); } body = body.Replace("{Addoffer}", templateItems.ToString()); txtCodeGenerate.Text = body; //Update Contaent in DB -------------------------------------------------------------- Int16 mailFormatType = Convert.ToInt16(Constants.MailFormatContentType.OfferContent); var contentMail = (from pro in model.Adv_MailContents where pro.MailType == mailFormatType select pro).SingleOrDefault(); if (contentMail != null) { contentMail.MailContent = body; model.SaveChanges(); } else { Adv_MailContent mailContent = new Adv_MailContent(); mailContent.MailContent = body; mailContent.MailType = Convert.ToInt16(Constants.MailFormatContentType.OfferContent); model.AddToAdv_MailContents(mailContent); model.SaveChanges(); } } } }