// Create or Update public override string PostAction(string parameters, NameValueCollection querystring, string postdata) { var data = string.Empty; var bvin = FirstParameter(parameters); var fileName = querystring["filename"]; var description = querystring["description"]; var firstPart = querystring["first"]; var response = new ApiResponse <bool>(); byte[] postedData = null; try { if (firstPart == "1") { var existing = HccApp.CatalogServices.ProductFiles.Find(bvin); if (existing == null || existing.Bvin == string.Empty) { existing.Bvin = bvin; existing.FileName = fileName; existing.ShortDescription = description; existing.StoreId = HccApp.CurrentStore.Id; HccApp.CatalogServices.ProductFiles.Create(existing); } } postedData = Json.ObjectFromJson <byte[]>(postdata); var diskFileName = bvin + "_" + fileName + ".config"; if (postedData != null) { if (postedData.Length > 0) { if (firstPart == "1") { response.Content = DiskStorage.FileVaultUploadPartial(HccApp.CurrentStore.Id, diskFileName, postedData, true); } else { response.Content = DiskStorage.FileVaultUploadPartial(HccApp.CurrentStore.Id, diskFileName, postedData, false); } } } } catch (Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(Json.ObjectToJson(response)); } data = Json.ObjectToJson(response); return(data); }