Пример #1
0
        // Create or Update
        public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata)
        {
            string data = string.Empty;
            string ids = FirstParameter(parameters);
            long id = 0;
            long.TryParse(ids, out id);
            ApiResponse<TaxDTO> response = new ApiResponse<TaxDTO>();

            TaxDTO postedCategory = null;
            try
            {
                postedCategory = MerchantTribe.Web.Json.ObjectFromJson<TaxDTO>(postdata);
            }
            catch(Exception ex)
            {
                response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
                return MerchantTribe.Web.Json.ObjectToJson(response);                
            }

            Tax item = new Tax();
            item.FromDto(postedCategory);

            if (id < 1)
            {
                if (!MTApp.OrderServices.Taxes.ExactMatchExists(item))
                {
                    if (MTApp.OrderServices.Taxes.Create(item))
                    {
                        id = item.Id;
                    }
                }
            }
            else
            {
                MTApp.OrderServices.Taxes.Update(item);
            }                               
            response.Content = item.ToDto();            
            data = MerchantTribe.Web.Json.ObjectToJson(response);            
            return data;
        }
Пример #2
0
        private void RenderTax(Tax t)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<tr>");
            sb.Append("<td align=\"middle\">" + t.CountryName + "</td>");
            sb.Append("<td>" + t.RegionAbbreviation + "</td>");
            sb.Append("<td>" + t.PostalCode + "</td>");
            sb.Append("<td>" + t.Rate.ToString("#.00") + "</td>");
            if (t.ApplyToShipping)
            {
                sb.Append("<td>Yes</td>");
            }
            else
            {
                sb.Append("<td>No</td>");
            }
            sb.Append("<td><a href=\"Taxes_Delete.aspx?id=" + t.Id.ToString() + "&sid=" + t.TaxScheduleId.ToString() + "\">Delete</a></td>");
            sb.Append("</tr>");

            this.litRates.Text += sb.ToString();
        }
Пример #3
0
        protected void btnNew_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            string sid = Request.QueryString["id"];
            long scheduleId = long.Parse(sid);

            Tax t = new Tax();
            t.CountryName = this.lstCountry.SelectedItem.Text;
            t.ApplyToShipping = this.ApplyToShippingCheckBox.Checked;
            t.PostalCode = this.postalCode.Text.Trim();
            t.Rate = decimal.Parse(this.Rate.Text.Trim());
            t.RegionAbbreviation = this.lstState.SelectedItem.Value;
            t.StoreId = MTApp.CurrentStore.Id;
            t.TaxScheduleId = scheduleId;

            MTApp.OrderServices.Taxes.Create(t);
            LoadSchedule(scheduleId);
        }