public ActionResult Upload(OnlinePortal.Models.Student employee) { using (OnlinePortal.Models.FacultyDBEntities1 entity = new OnlinePortal.Models.FacultyDBEntities1()) { var candidate = new Candidate() { EmailID = employee.EmailID, FirstName = employee.FirstName, LastName = employee.LastName, Prof_Id = employee.Prof_Id, Resume = SaveToPhysicalLocation(employee.LabFile), CreatedOn = DateTime.Now }; TempData.Add("MyTempData", employee.EmailID); entity.Candidates.Add(candidate); entity.SaveChanges(); if (candidate.Prof_Id != null) { return(RedirectToAction("Students")); } } return(View(employee)); }
public ActionResult AddOrEdit(OnlinePortal.Models.Candidate emp) { try { using (OnlinePortal.Models.FacultyDBEntities1 db = new OnlinePortal.Models.FacultyDBEntities1()) { if (emp.ID == 0) { db.Candidates.Add(emp); db.SaveChanges(); } else { db.Entry(emp).State = EntityState.Modified; db.SaveChanges(); } } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllStudentsdetails()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { try { using (OnlinePortal.Models.FacultyDBEntities1 db = new OnlinePortal.Models.FacultyDBEntities1()) { OnlinePortal.Models.Candidate emp = db.Candidates.Where(x => x.ID == id).FirstOrDefault <OnlinePortal.Models.Candidate>(); db.Candidates.Remove(emp); db.SaveChanges(); } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllStudentsdetails()), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }