public IHttpActionResult Post(Employee employee) { if (!(ModelState.IsValid && employeeObjBs.Insert(employee))) { return(SendBadRequest()); } return(CreatedAtRoute("DefaultApi", new { id = employee.EmployeeId }, employee)); }
public IHttpActionResult Post(Employee employee) { if (ModelState.IsValid) { // Business rule validation if (employeeObjBs.Insert(employee)) { return(CreatedAtRoute("Defaultapi", new { id = employee.EmployeeId }, employee)); } else { foreach (var error in employeeObjBs.Errors) { ModelState.AddModelError("", error); } return(BadRequest(ModelState)); } } else { return(BadRequest(ModelState)); } }