public JsonResult CreateSkill(Skill skill) { try { if (!ModelState.IsValid) { return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }); } var addedSkill = db.Skills.Add(skill); db.SaveChanges(); return Json(new { Result = "OK", Record = addedSkill }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
public JsonResult UpdateSkill(Skill skill) { try { if (!ModelState.IsValid) { return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }); } db.Entry(skill).State = EntityState.Modified; db.SaveChanges(); return Json(new { Result = "OK" }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }