protected void btnSave_Click(System.Object sender, System.Web.UI.ImageClickEventArgs e)
        {
            msg.ClearMessage();
            ProductType prodType = new ProductType();
            prodType = MTApp.CatalogServices.ProductTypes.Find(this.BvinField.Value);
            if (prodType != null)
            {

                prodType.ProductTypeName = this.ProductTypeNameField.Text;

                if (MTApp.CatalogServices.ProductTypes.Update(prodType) == true)
                {
                    prodType = null;
                    Response.Redirect("ProductTypes.aspx");
                }
                else
                {
                    prodType = null;
                    msg.ShowError("Error: Couldn't Save Product Type!");
                }
            }
            else
            {
                msg.ShowError("Couldn't Load Product Type to Update!");
            }

        }
Exemplo n.º 2
0
 protected void btnNew_Click(System.Object sender, System.Web.UI.ImageClickEventArgs e)
 {
     ProductType pt = new ProductType();
     if (MTApp.CatalogServices.ProductTypes.CreateAsNew(pt))
     {
         Response.Redirect("~/BVAdmin/Catalog/ProductTypesEdit.aspx?newmode=1&id=" + pt.Bvin);
     }
     else
     {
         msg.ShowError("Error while attempting to create new type.");
     }
 }
        private void LoadType()
        {
            ProductType prodType = new ProductType();
            prodType = MTApp.CatalogServices.ProductTypes.Find(this.BvinField.Value);
            if (prodType != null)
            {

                this.ProductTypeNameField.Text = prodType.ProductTypeName;

                LoadPropertyLists();

                if (MTApp.CatalogServices.Products.FindCountByProductType(prodType.Bvin) > 0)
                {
                    msg.ShowWarning("Editing this type will affect all existing products of this type. Any default values you set here will NOT overwrite existing products but any properties that you add or remove will affect existing products.");
                }
            }
            else
            {
                msg.ShowError("Unable to load Product Type ID " + ViewState["ID"]);
            }
        }
Exemplo n.º 4
0
        // Create or Update
        public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata)
        {
            string data = string.Empty;
            string bvin = FirstParameter(parameters);
            
            //
            // <site Url>/producttypes/<guid>/properties/<propertyid>/<sortOrder>
            //
            string isProperty = GetParameterByIndex(1, parameters);
            if (isProperty.Trim().ToLowerInvariant() == "properties")
            {
                ApiResponse<bool> response2 = new ApiResponse<bool>();

                string propertyIds = GetParameterByIndex(2, parameters);
                long propertyId = 0;
                long.TryParse(propertyIds, out propertyId);                              

                response2.Content = MTApp.CatalogServices.ProductTypeAddProperty(bvin, propertyId);
                data = MerchantTribe.Web.Json.ObjectToJson(response2);            
            }
            else
            {
                ApiResponse<ProductTypeDTO> response = new ApiResponse<ProductTypeDTO>();
                ProductTypeDTO postedItem = null;
                try
                {
                    postedItem = MerchantTribe.Web.Json.ObjectFromJson<ProductTypeDTO>(postdata);
                }
                catch (Exception ex)
                {
                    response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
                    return MerchantTribe.Web.Json.ObjectToJson(response);
                }

                ProductType item = new ProductType();
                item.FromDto(postedItem);

                if (bvin == string.Empty)
                {
                    if (MTApp.CatalogServices.ProductTypes.Create(item))
                    {
                        bvin = item.Bvin;
                    }
                }
                else
                {
                    MTApp.CatalogServices.ProductTypes.Update(item);
                }
                ProductType resultItem = MTApp.CatalogServices.ProductTypes.Find(bvin);
                if (resultItem != null) response.Content = resultItem.ToDto();
                data = MerchantTribe.Web.Json.ObjectToJson(response);            
            }


            
            return data;
        }