private List <Merchant_Offer> SetDTinValues(DataTable dt) { List <Merchant_Offer> offers = new List <Merchant_Offer>(); foreach (DataRow row in dt.Rows) { if (!string.IsNullOrEmpty(row["Merchant"].ToString())) { Merchant_Offer offer = new Merchant_Offer(); offer.MID = uc_MerchantDDlList.GetValueFindByText(row["Merchant"].ToString()); //offer.MID = row["Program"].ToString(); //offer.MID = row["AffWebsite"].ToString(); offer.Title = row["OfferTitle"].ToString(); offer.CouponCode = row["CouponCode"].ToString(); offer.Description = row["Description"].ToString(); if (!string.IsNullOrEmpty(row["ValidTill"].ToString())) { offer.ValidTill = Convert.ToDateTime(row["ValidTill"].ToString()); } else { offer.ValidTill = null; } if (string.IsNullOrEmpty(row["Device"].ToString())) { offer.CouponForDevice = Constants.Device.Desktop; } else { offer.CouponForDevice = (Constants.Device)Enum.Parse(typeof(Constants.Device), row["Device"].ToString()); } if (!string.IsNullOrEmpty(row["Program"].ToString()) && !string.IsNullOrEmpty(row["AffWebsite"].ToString())) { if (row["AffWebsite"].ToString() == Constants.MerchantDeepLinkType.Payoom.ToString()) { string programURL = uc_DeepLinkUrlDDL.GetValueFindByText(row["Program"].ToString()); string url = programURL + "&url=" + row["NavigationURL"].ToString(); offer.NavigationURL = url; } else if (row["AffWebsite"].ToString() == Constants.MerchantDeepLinkType.OMGPM.ToString()) { string programURL = uc_DeepLinkUrlDDL.GetValueFindByText(row["Program"].ToString()); string url = programURL + "&r=" + row["NavigationURL"].ToString(); offer.NavigationURL = url; } else { offer.NavigationURL = null; } } offers.Add(offer); } } return(offers); }
void _view_BulkInsert(object sender, EventArgs e) { try { foreach (Merchant_Offer _item in _view.Merchant_Offers) { Merchant_Offer c = new Merchant_Offer(); c.MID = _item.MID; c.CouponForDevice = _item.CouponForDevice; c.Title = _item.Title; c.Description = _item.Description; c.ValidTill = _item.ValidTill; c.NavigationURL = _item.NavigationURL; c.CouponCode = _item.CouponCode; _model.DBOperation(Constants.Action.Insert, c); } _view.strMessage = "Successfully bulk insert added!!!"; LoadViewFromModel(); _view.DataBind(); } catch (Exception ex) { _view.strMessage = ex.InnerException.Message; } }
void _view_DeleteCommand(object sender, EventArgs e) { try { Merchant_Offer c = new Merchant_Offer(); _model.DBOperation(Constants.Action.Delete, c, _view.OfferIds); _view.strMessage = "Successfully Deleted!!!"; LoadViewFromModel(); _view.DataBind(); } catch (Exception ex) { _view.strMessage = ex.Message; } }
public void DBOperation(Constants.Action command, Merchant_Offer item = null, List <Int64> Ids = null) { switch (command) { case Constants.Action.Insert: client.InsertOffer(item); break; case Constants.Action.Delete: client.DeleteOffers(Ids); break; default: break; } }
void _view_InsertCommand(object sender, EventArgs e) { try { if (_view.Merchant_Offers == null) { Merchant_Offer c = new Merchant_Offer(); c.MID = _view.MID; c.CouponForDevice = (Constants.Device)_view.CouponForDevice; c.Title = _view.Title; c.Description = _view.Description; c.ValidTill = _view.ValidTill; c.NavigationURL = _view.NavigationURL; c.CouponCode = _view.CouponCode; c.VoucherCodeID = _view.VoucherCodeID; c.ActivationDate = _view.StartDate; c.OfferType = _view.OfferType; _model.DBOperation(Constants.Action.Insert, c); _view.strMessage = "Successfully Inserted!!!"; LoadViewFromModel(); c.Title = string.Empty; c.Description = string.Empty; c.NavigationURL = string.Empty; c.CouponCode = string.Empty; } else { foreach (Merchant_Offer _item in _view.Merchant_Offers) { _model.DBOperation(Constants.Action.Insert, _item); } _view.strMessage = "Successfully insert!!!"; } _view.DataBind(); } catch (Exception ex) { _view.strMessage = ex.InnerException.Message; } }
private List <Merchant_Offer> SetDTinValuesOfPayoomCSV(DataTable dt) { List <Merchant_Offer> offers = new List <Merchant_Offer>(); foreach (DataRow row in dt.Rows) { if (!string.IsNullOrEmpty(row["Campaign"].ToString())) { Merchant_Offer offer = new Merchant_Offer(); Uri myUri = new Uri(row["LandingPage"].ToString()); string omgmid = HttpUtility.ParseQueryString(myUri.Query).Get("Offer_ID"); offer.MID = uc_MerchantDDlList.GetMIDByAMID(Convert.ToInt32(omgmid), row["Campaign"].ToString()); if (offer.MID > 0) { //offer.MID = row["Program"].ToString(); //offer.MID = row["AffWebsite"].ToString(); offer.Title = row["CouponTitle"].ToString(); offer.CouponCode = row["CouponCode"].ToString(); //offer.Description = row["Description"].ToString(); if (!string.IsNullOrEmpty(row["EndDate"].ToString())) { // offer.ValidTill = Convert.ToDateTime(row["EndDate"].ToString()); string dtFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; if (row["EndDate"].ToString().Contains("-")) { if (dtFormat == "dd/MM/yyyy") { offer.ValidTill = DateTime.ParseExact(row["EndDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } else { offer.ValidTill = DateTime.ParseExact(row["EndDate"].ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture); } } else { try { if (dtFormat == "dd/MM/yyyy") { offer.ValidTill = DateTime.ParseExact(row["EndDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); } else { offer.ValidTill = DateTime.ParseExact(row["EndDate"].ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture); } } catch (Exception ex) { offer.ValidTill = Convert.ToDateTime(row["EndDate"].ToString()); } } } else { offer.ValidTill = null; } if (!string.IsNullOrEmpty(row["StartDate"].ToString())) { offer.ActivationDate = Convert.ToDateTime(row["StartDate"].ToString()); } else { offer.ActivationDate = null; } //if (string.IsNullOrEmpty(row["Device"].ToString())) // offer.CouponForDevice = Constants.Device.Desktop; //else // offer.CouponForDevice = (Constants.Device)Enum.Parse(typeof(Constants.Device), row["Device"].ToString()); offer.NavigationURL = row["LandingPage"].ToString(); offers.Add(offer); } } } return(offers); }
protected void btnSubmitOffer_Click(object sender, EventArgs e) { List <Merchant_Offer> offers = new List <Merchant_Offer>(); DataTable dt = new DataTable("Item"); EventHandler Insert = this.InsertCommand; if (rbListUrl.Checked) { XElement xele = XElement.Load(Constants.OmgVoucherCode); dt = clsFileToTable.XElementToDataTable(xele); dt.Columns["ExpiryDate"].GetType(); //var offer = (from o in dt.AsEnumerable() // select new Merchant_Offer() // { // Title = o.Field<string>("Title"), // VoucherCodeID =Convert.ToInt32(o.Field<string>("VoucherCodeID")), // MID =uc_MerchantDDlList.GetValueFindByText(o.Field<string>("Merchant").ToString()),// o.Field<string>("Title"), // Description = o.Field<string>("Description"), // CouponCode = o.Field<string>("Code"), // ValidTill = Convert.ToDateTime(string.IsNullOrEmpty(o.Field<string>("ExpiryDate")) ? DateTime.Now.AddYears(1).ToString() : o.Field<string>("ExpiryDate")).Date, // ActivationDate = Convert.ToDateTime(string.IsNullOrEmpty(o.Field<string>("ActivationDate")) ? DateTime.Now.AddYears(1).ToString() : o.Field<string>("ActivationDate")).Date, // NavigationURL = o.Field<string>("TrackingURL"), // OfferType = Convert.ToInt16(Constants.Adv_Type.Offer) // }); //foreach (Merchant_Offer ooo in offer) //{ // if (ooo.MID > 0) // offers.Add(ooo); //} foreach (DataRow row in dt.Rows) { Merchant_Offer itemOffer = new Merchant_Offer(); Int64 merID = uc_MerchantDDlList.GetValueFindByText(row["Merchant"].ToString()); if (merID != 0) { itemOffer.Title = row["Title"].ToString(); if (row["VoucherCodeID"].ToString() != "") { itemOffer.VoucherCodeID = Convert.ToInt32(row["VoucherCodeID"].ToString()); } //this.co Code = row.Cells[3].Text; itemOffer.MID = merID; itemOffer.Description = row["Description"].ToString(); itemOffer.CouponCode = row["Code"].ToString(); string[] vDate = null; if (row["ExpiryDate"].ToString() != "") { vDate = row["ExpiryDate"].ToString().Split('/'); } if (vDate != null && vDate.Length > 1) { itemOffer.ValidTill = Convert.ToDateTime(vDate[1] + "/" + vDate[0] + "/" + vDate[2]); } if (row["ActivationDate"].ToString() != "") { vDate = row["ActivationDate"].ToString().Split('/'); } if (vDate != null && vDate.Length > 1) { itemOffer.ActivationDate = Convert.ToDateTime(vDate[1] + "/" + vDate[0] + "/" + vDate[2]); } itemOffer.NavigationURL = row["TrackingURL"].ToString(); itemOffer.OfferType = Convert.ToInt16(Constants.Adv_Type.Offer); offers.Add(itemOffer); } } if (Insert != null) { //lblMessage.Text = string.Empty; this.Merchant_Offers = offers;//.ToList();// offers; Insert(this, e); clsProcCallingService.Proc_UpdateDeleteDupilcateOffers(); BindItems(); } } //foreach (GridViewRow row in gvXMLDate.Rows) //{ // CheckBox chkXMLData = row.Cells[0].Controls[0].FindControl("chkRow") as CheckBox; // if (chkXMLData.Checked) // { // //Title // //string vcodeID=row.Cells[1].Text; // this.Title = row.Cells[4].Text; // //this.co Code = row.Cells[3].Text; // // this.MID= // this.Description = row.Cells[5].Text; // this.CouponCode = row.Cells[3].Text; // string[] vDate = null; // if (row.Cells[7].Text != "") // vDate = row.Cells[7].Text.Split('/'); // if (vDate.Length > 1) // this.ValidTill = Convert.ToDateTime(vDate[1] + "/" + vDate[0] + "/" + vDate[2]); // this.NavigationURL = row.Cells[8].Text; // if (Insert != null) // { // //lblMessage.Text = string.Empty; // Insert(this, e); // BindItems(); // } // //this.Title=chkXMLData.XMLDataTable.se // } //} }