public JsonResult Deactivate(int Id) { try { Candidate Candidate = new Candidate(Id); Candidate.Active = false; Candidate.Save(); return new JsonResult { Data = new { success = true } }; // Return nothing as there are no errors } catch (Exception ex) { return new JsonResult { Data = new { success = false, error = ex.Message } }; } }
public JsonResult Save(Candidate Candidate) { try { MembershipUser user = Membership.GetUser(User.Identity.Name); Candidate.UserId = user.ProviderUserKey.ToString(); Candidate.UserName = user.UserName; Candidate.Save(); return new JsonResult { Data = new { success = true, id = Candidate.Id } }; // Return the candidate Id if there are no errors } catch (Exception ex) { return new JsonResult { Data = new { success = false, error = ex.Message } }; } }