// 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; }