- Forum posts: 1
Apr 17, 2018, 2:06:00 PM via Website
Apr 17, 2018 2:06:00 PM via Website
Hi all
I have an asp.net web api:
[Action]
public virtual async Task AddCustomer(Customer customer, CancellationToken cancellation)
{
Customer existingCustomer = (await Repository.GetAllAsync(cancellation)).Where(cu => cu.NationalCode == customer.NationalCode).FirstOrDefault();
if (existingCustomer != null)
throw new Exception("you registered before. please login");
return await Repository.AddAsync(customer, cancellation);
}
I could post to this api in react native by this code :
var url = '/Sanaap.Api/odata/Sanaap/Customers/Sanaap.LoginCustomer';
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
FirstName: '',
LastName: '',
NationalCode: this.state.ncode.toString(),
Mobile: this.state.mobile.toString(),
})
}).then((response) => {
if (response.status == 500) {
alert('500');
Toast.show({
text: "not found",
position: 'bottom', duration: 5000, type: 'danger'
});
return;
}
if (response.status == 200) {
alert('200');
this.props.navigation.navigate("EvalReq");
}
});
what is equal code in android studio instead of fetch for post a customer and get inserted customer id?
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.