I had develop blazorWASM aplication.
In this appllication I want to generate unique order id thats why I had choose snowflakeid to avoid duplicate orders
I had used snowflakeid nuget package as below procedure https://www.nuget.org/packages/SnowflakeIDGenerator
I had generate the snowflakeid using machineid and customepoch. snowflakid type is long
that snowflakeid want to maintain in db and I had passed the snowflakeid through api using serialization process at the time snowflakeid value changed like
snowflakeid original value: 526688986857484300
snowflakeid changed value:526688986857484304
For suppose before seralization If i changed the type to string at the time also snowflakeid changed
I know Issue happened If i do change the long to string thats why I had ignore type conversion. I know largeinter numbers or snowflake id changed when conversion thats why i had ignored but when seralization also issue happened
public async Task<Orders> Updateorder(Orders order, IHttpClientFactory clientFactory)
{
var getorder = new Orders();
try
{
var client = clientFactory.CreateClient("WebAPI");
var updaterequest = new HttpRequestMessage(HttpMethod.Post, "api/Orders/UpdateOrder");
POSOrderRequest request = new POSOrderRequest();
request.Baseobject=order;
string serializedData = JsonConvert.SerializeObject(request);
StringContent content = new StringContent(serializedData, Encoding.UTF8, "application/json");
var response = await client.PostAsync(updaterequest.RequestUri, content);
if (response.IsSuccessStatusCode)
{
var updatereponse = response.Content.ReadAsStringAsync().Result;
UpdateOrderapireposne apires = JsonConvert.DeserializeObject<UpdateOrderapireposne>(updatereponse);
getorder = apires.BaseObject;
}
}
catch (Exception ex)
{
}
return getorder;
}
I want to maintain Snowflake id value preserved when passing to webapi
Please help me. Thank you.
What I have tried:
I want to maintain Snowflake id value preserved when passing to webapi