[HttpPost]
public HttpResponseMessage Registration(RegistrationRequest reg)
{
if (ModelState.IsValid)
{
return Request.CreateResponse(HttpStatusCode.OK);
}
IEnumerable<string> errors = ModelState.Values.SelectMany(v => v.Errors.Select(b =>
b.ErrorMessage));
string strErrors = string.Join("; ", errors);
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, strErrors);
}
OR
[HttpPost]
public HttpResponseMessage Registration(RegistrationRequest reg)
{
if (ModelState.IsValid)
{
return Request.CreateResponse(HttpStatusCode.OK);
}
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
This comment has been removed by a blog administrator.
ReplyDelete