public ActionResult Edit(int Id) { Candidate Candidate = new Candidate(Id); Collection<GenericType> Rates = GenericProvider.GetSalaryRates(); SelectList TempRate = (Candidate.SalaryDetails().TempRateId > 0) ? new SelectList(Rates, "Id", "Name", Candidate.SalaryDetails().TempRateId) : new SelectList(Rates, "Id", "Name", 1); SelectList PermRate = (Candidate.SalaryDetails().PermRateId > 0) ? new SelectList(Rates, "Id", "Name", Candidate.SalaryDetails().PermRateId) : new SelectList(Rates, "Id", "Name", 1); ViewBag.TempRateId = TempRate; ViewBag.PermRateId = PermRate; return View(Candidate); }
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 } }; } }