void _view_BulkInsert(object sender, EventArgs e)
    {
        try
        {
            foreach (Merchant_Coupon _item in _view.Merchant_Coupons)
            {
                Merchant_Coupon c = new Merchant_Coupon();

                c.MID             = _item.MID;
                c.CouponForDevice = _item.CouponForDevice;
                c.Coupon          = _item.Coupon;
                c.Offer           = _item.Offer;
                c.ValidTill       = _item.ValidTill;
                c.NavigationURL   = _item.NavigationURL;

                _model.DBOperation(Constants.Action.Insert, c);
            }
            _view.strMessage = "Successfully bulk insert added!!!";
            LoadViewFromModel();

            _view.DataBind();
        }
        catch (Exception ex)
        {
            _view.strMessage = ex.Message;
        }
    }
Beispiel #2
0
    private List <Merchant_Coupon> SetDTinValues(DataTable dt)
    {
        List <Merchant_Coupon> offers = new List <Merchant_Coupon>();

        foreach (DataRow row in dt.Rows)
        {
            if (!string.IsNullOrEmpty(row["Merchant"].ToString()))
            {
                Merchant_Coupon offer = new Merchant_Coupon();

                offer.MID = uc_MerchantDDlList.GetValueFindByText(row["Merchant"].ToString());
                //offer.MID = row["Program"].ToString();
                //offer.MID = row["AffWebsite"].ToString();
                offer.Coupon = row["CouponCode"].ToString();
                offer.Offer  = row["Description"].ToString();

                if (!string.IsNullOrEmpty(row["ValidTill"].ToString()))
                {
                    offer.ValidTill = Convert.ToDateTime(row["ValidTill"].ToString());
                }


                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_DeleteCommand(object sender, EventArgs e)
    {
        try
        {
            Merchant_Coupon c = new Merchant_Coupon();
            _model.DBOperation(Constants.Action.Delete, c, _view.Ids);
            _view.strMessage = "Successfully Deleted!!!";
            LoadViewFromModel();

            _view.DataBind();
        }
        catch (Exception ex)
        {
            _view.strMessage = ex.Message;
        }
    }
Beispiel #4
0
    public void DBOperation(Constants.Action command, Merchant_Coupon item = null, List <Int64> Ids = null)
    {
        switch (command)
        {
        case Constants.Action.Insert:
            client.InsertCoupon(item);
            break;

        case Constants.Action.Delete:
            client.DeleteCoupons(Ids);
            break;

        default:
            break;
        }
    }
    void _view_InsertCommand(object sender, EventArgs e)
    {
        try
        {
            Merchant_Coupon var = new Merchant_Coupon();

            var.MID             = _view.MID;
            var.Coupon          = _view.Coupon;
            var.CouponForDevice = (Constants.Device)_view.CouponForDevice;
            var.Offer           = _view.Offer;
            var.ValidTill       = _view.ValidTill;
            var.NavigationURL   = _view.NavigationURL;

            _model.DBOperation(Constants.Action.Insert, var);
            _view.strMessage = "Successfully Inserted!!!";
            LoadViewFromModel();
            _view.DataBind();
        }
        catch (Exception ex)
        {
            _view.strMessage = ex.Message;
        }
    }