public JsonResult AssignMe(long id) { long specialistId = -1; try { if (!long.TryParse(Session["SpecialistId"].ToString(), out specialistId)) { return(Json(new { rs = -1, msg = "Error: Can't get specialist's profile" }, JsonRequestBehavior.AllowGet)); } var can = db.Candidates.FirstOrDefault(s => s.CandidateId == id); if (can == null) { return(Json(new { rs = -1, msg = "Can not get candiate's profile" }, JsonRequestBehavior.AllowGet)); } if (can.SpecialistId == -1) { can.SpecialistId = specialistId; db.Entry(can).State = EntityState.Modified; var r = db.SaveChanges(); return(Json(new { rs = 1, msg = "Error: Can't get specialist's profile" }, JsonRequestBehavior.AllowGet)); } return(Json(new { rs = -1, msg = "Can not assign this candiate" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { rs = -1, msg = e.Message }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Edit([Bind(Include = "SpecialistId,FirstName,MiddleName,LastName,Email,PhoneNumber,Role,UserLoginId")] Specialist specialist) { if (ModelState.IsValid) { db.Entry(specialist).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(specialist)); }
public JsonResult UpdateCandidate(CandidateSimpleInfo can) { long clientId = -1; if (!long.TryParse(Session["ClientId"].ToString(), out clientId)) { return(Json(new { rs = -1, msg = "Permission Denied" }, JsonRequestBehavior.AllowGet)); } long recruiterId = -1; if (!long.TryParse(Session["RecruiterId"].ToString(), out recruiterId)) { return(Json(new { rs = -1, msg = "Permission Denied" }, JsonRequestBehavior.AllowGet)); } var candidate = db.Candidates.First(s => s.CandidateId == can.CandidateId && s.ClientId == clientId); if (candidate == null) { return(Json(new { rs = -1, msg = "Permission Denied" }, JsonRequestBehavior.AllowGet)); } if (candidate.Status != "Initial") { return(Json(new { rs = -1, msg = "Error: Can not edit candidate information when they submitted" }, JsonRequestBehavior.AllowGet)); } candidate.FirstName = can.FirstName; candidate.MiddleName = can.MiddleName; candidate.LastName = can.LastName; candidate.Email = can.Email; candidate.PhoneNumber = can.PhoneNumber; candidate.JobTitle = can.JobTitle; candidate.JobLevel = can.JobLevel; db.Entry(candidate).State = EntityState.Modified; var r = db.SaveChanges(); var log = new ClientLog() { RecruiterId = candidate.RecruiterId, LogType = "Update Candidate", LogTime = DateTime.Now, ClientId = candidate.ClientId, LogContent = "Update candidate " + can.FirstName + " " + can.MiddleName + " " + can.LastName }; db.ClientLogs.Add(log); db.SaveChanges(); return(Json(new { rs = candidate.CandidateId, msg = r }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> EditProfile([Bind(Include = "CandidateId,FirstName,MiddleName,LastName,Email,PhoneNumber,Address,Gender,DOB,JobTitle,JobLevel,IDNumber")] Candidate candidate) { long userId = -1; if (!long.TryParse(Session["UserId"].ToString(), out userId)) { return(RedirectToAction("Error", "Error")); } var can = db.Candidates.FirstOrDefault(s => (s.CandidateId == candidate.CandidateId && s.UserLoginId == userId)); if (candidate == null) { return(RedirectToAction("Error", "Error")); } can.FirstName = candidate.FirstName; can.MiddleName = candidate.MiddleName; can.LastName = candidate.LastName; can.Email = candidate.Email; can.PhoneNumber = candidate.PhoneNumber; can.Address = candidate.Address; can.Gender = candidate.Gender; can.DOB = candidate.DOB; can.JobLevel = candidate.JobLevel; can.JobTitle = candidate.JobTitle; can.IDNumber = candidate.IDNumber; can.Status = "Ready"; if (ModelState.IsValid) { db.Entry(can).State = EntityState.Modified; await db.SaveChangesAsync(); // log out return(RedirectToAction("Login", "Home")); } return(RedirectToAction("Login", "Home")); }