public ActionResult Update(EmployeeVM employee) { if (ModelState.IsValid) { return new HttpStatusCodeResult(HttpStatusCode.OK, "Employee updated"); } var errors = new List<string> { "Update failed." }; if (!ModelState.IsValidField("Notes")) { errors.Add("Notes must be at least 5 characters long"); } return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, String.Join(" ", errors)); }
public ActionResult Create(EmployeeVM employee) { if (ModelState.IsValid) { var id = new { id = 12345 }; return GetJsonContentResult(id); return new HttpStatusCodeResult(HttpStatusCode.Created, "New employee added"); } var errors = new List<string> { "Insert failed." }; if (!ModelState.IsValidField("Notes")) { errors.Add("Notes must be at least 5 characters long"); } return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, String.Join(" ", errors)); }