public ActionResult Update(EmployeeVM employee) { if (ModelState.IsValid) { return new HttpStatusCodeResult(HttpStatusCode.OK, "Update success"); } List<string> errors = new List<string>(); errors.Add("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) { return new HttpStatusCodeResult(201, "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)); }
public ActionResult Create(EmployeeVM employee) { if (ModelState.IsValid) { var id = new { id = 12345 }; return GetJsonContentResult(id); } List<string> errors = new List<string>(); errors.Add("Insert failed."); if (!ModelState.IsValidField("Notes")) errors.Add("Notes must be at least 5 characters long."); return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, String.Join(" ", errors)); }