This is the display side
function Load () {
$.ajax ({
Type: "Post",
URL: "Http://localhost:63211/api/MeetingRoomService/AddMeetiongType",
DataType: "JSON",
Data: {"Typename": "123"},
Success:function (data) {
Rendercontactlist (data);
alert (data.data);
},error:function (XMLHttpRequest, Textstatus, Errorthrown) {
alert (data.data);
}
});
}
This is the service side
[HttpPost]
Public resultentity<bool> addmeetiongtype ([Frombody]meetingtype MT)
{
Exceptionmanager.handle (New Exception ("typename>>>>>>" + Mt. Typename));
resultentity<bool> result = new resultentity<bool> ();
Result.errors = new list<errorentity> ();
Errorentity error = new errorentity ();
Result.action_code = ActionCode.SUCCESS.ToString ();
Try
{
Check.checkparameter (Mt. Typename);
if (BLL. Getmeetingroomtypeexist (Mt. Typename) = = False)
{
if (BLL. Addmeetingroomtype (Mt. Typename))
{
Error.message = "Insert succeeded";
Result.data = true;
}
Else
{
Result.action_code = ActionCode.FAILED.ToString ();
Error.message = "Insert Failed";
Result.data = false;
}
}
Else
{
Result.action_code = ActionCode.FAILED.ToString ();
Error.message = "This information already exists";
}
}
catch (ArgumentException E)
{
Exceptionmanager.handle (e);
Result.action_code = ActionCode.FAILED.ToString ();
Error.message = E.message;
}
catch (Exception ex)
{
Exceptionmanager.handle (ex);
Result.action_code = ActionCode.FAILED.ToString ();
Error.message = "An error occurred in adding the type interface!" ";
}
RESULT.ERRORS.ADD (Error);
return result;
}
The first Web API post program
Today, I forgot to judge whether a dataset is empty.
Ds. Tables[0]. Rows.Count >0