public ActionResult DeleteConfirmed(long id) { Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); db.Employee_Personal_Detail.Remove(employee_Personal_Detail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(long?id, string name) { long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "admin") { ViewBag.Role = "admin"; if (name != null) { bool isThere = db.Employee_Personal_Detail.Any(x => x.EMP_ID == id.Value); if (!isThere) { return(RedirectToAction("Create", "EmployeePersonalDetail", new { ID = id.Value })); } else { ViewBag.EditVisible = "No"; Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Where(x => x.EMP_ID == id.Value).FirstOrDefault(); return(View(employee_Personal_Detail)); } } } bool isExist = db.Employee_Personal_Detail.Any(x => x.EMP_ID == emp_id); if (!isExist) { return(RedirectToAction("Create")); } else { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} if (role == "emp") { id = db.Employee_Personal_Detail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); } Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); if (employee_Personal_Detail == null) { return(HttpNotFound()); } return(View(employee_Personal_Detail)); } }
// GET: EmployeePersonalDetail/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); if (employee_Personal_Detail == null) { return(HttpNotFound()); } return(View(employee_Personal_Detail)); }
public ActionResult Edit([Bind(Include = "ID,Gender,DOB,Category,IdentityMark1,IdentityMark2,Religion,Citizenship,Caste,Race,MarraigeStatus,MarraigeDate,NoOfChild,NoOfDependents,AadharNo,SIN,AKA,MilitaryService,BirthCity,Note,Hobbies,MilitaryServiceDetail,EMP_ID")] Employee_Personal_Detail employee_Personal_Detail) { //removed EMP_ID from model bind because its only ReadOnly long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "emp") { ModelState.Remove("EMP_ID"); employee_Personal_Detail.EMP_ID = emp_id; } if (ModelState.IsValid) { db.Entry(employee_Personal_Detail).State = EntityState.Modified; db.SaveChanges(); if (role == "emp") { long id = db.Employee_Personal_Detail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); return(RedirectToAction("Details", "EmployeePersonalDetail", new { id })); } ViewBag.success = "Your Record Successfully Updated!"; ViewBag.Caste = new SelectList(db.CastMaster.Where(x => x.ReligionID == employee_Personal_Detail.Religion), "CastCode", "CastName"); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", employee_Personal_Detail.Category); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM", employee_Personal_Detail.Citizenship); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value", employee_Personal_Detail.Gender); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName", employee_Personal_Detail.MarraigeStatus); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName", employee_Personal_Detail.Religion); if (role == "admin") { ViewBag.Role = "admin"; } return(View(employee_Personal_Detail)); } ViewBag.Caste = new SelectList(db.CastMaster.Where(x => x.ReligionID == employee_Personal_Detail.Religion), "CastCode", "CastName"); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", employee_Personal_Detail.Category); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM", employee_Personal_Detail.Citizenship); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value", employee_Personal_Detail.Gender); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName", employee_Personal_Detail.MarraigeStatus); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName", employee_Personal_Detail.Religion); if (role == "admin") { ViewBag.Role = "admin"; } return(View(employee_Personal_Detail)); }
public bool Delete(long id) { Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); if (employee_Personal_Detail != null) { db.Employee_Personal_Detail.Remove(employee_Personal_Detail); db.SaveChanges(); return(true); } else { return(false); } }
public ActionResult Edit([Bind(Include = "ID,Gender,DOB,Category,IdentityMark1,IdentityMark2,Religion,Citizenship,Caste,Race,MarraigeStatus,MarraigeDate,NoOfChild,NoOfDependents,AadharNo,SIN,AKA,MilitaryService,BirthCity,Note,Hobbies,MilitaryServiceDetail,EmployeeID")] Employee_Personal_Detail employee_Personal_Detail) { if (ModelState.IsValid) { db.Entry(employee_Personal_Detail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Caste = new SelectList(db.CastMasters, "CastCode", "CastName", employee_Personal_Detail.Caste); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", employee_Personal_Detail.Category); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM", employee_Personal_Detail.Citizenship); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value", employee_Personal_Detail.Gender); ViewBag.MarraigeStatus = new SelectList(db.MaritalMasters, "MaritalID", "MaritalName", employee_Personal_Detail.MarraigeStatus); ViewBag.Religion = new SelectList(db.ReligionMasters, "ReligionID", "ReligionShortName", employee_Personal_Detail.Religion); return(View(employee_Personal_Detail)); }
// GET: EmployeePersonalDetail/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); if (employee_Personal_Detail == null) { return(HttpNotFound()); } ViewBag.Caste = new SelectList(db.CastMasters, "CastCode", "CastName", employee_Personal_Detail.Caste); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", employee_Personal_Detail.Category); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM", employee_Personal_Detail.Citizenship); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value", employee_Personal_Detail.Gender); ViewBag.MarraigeStatus = new SelectList(db.MaritalMasters, "MaritalID", "MaritalName", employee_Personal_Detail.MarraigeStatus); ViewBag.Religion = new SelectList(db.ReligionMasters, "ReligionID", "ReligionShortName", employee_Personal_Detail.Religion); return(View(employee_Personal_Detail)); }
public ActionResult Edit(long?id) { long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "admin") { ViewBag.Role = "admin"; } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //URL Attack if (role == "emp") { id = db.Employee_Personal_Detail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); } Employee_Personal_Detail employee_Personal_Detail = db.Employee_Personal_Detail.Find(id); if (employee_Personal_Detail == null) { return(HttpNotFound()); } // ViewBag.Caste = new SelectList(db.CastMasters, "CastCode", "CastName", employee_Personal_Detail.Caste); ViewBag.Caste = new SelectList(db.CastMaster.Where(x => x.ReligionID == employee_Personal_Detail.Religion), "CastCode", "CastName"); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", employee_Personal_Detail.Category); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM", employee_Personal_Detail.Citizenship); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value", employee_Personal_Detail.Gender); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName", employee_Personal_Detail.MarraigeStatus); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName", employee_Personal_Detail.Religion); return(View(employee_Personal_Detail)); }
public ActionResult Create(long?ID) { Employee_Personal_Detail obj = new Employee_Personal_Detail(); long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "admin") { ViewBag.Role = "admin"; obj.EMP_ID = ID.Value; bool isExist = db.Employee_Personal_Detail.Any(x => x.EMP_ID == obj.EMP_ID); if (isExist) { return(RedirectToAction("Create", "EmployeeContactDetails", new { ID = obj.EMP_ID })); } } //if attck by direct URL if (role == "emp") { bool isExist = db.Employee_Personal_Detail.Any(x => x.EMP_ID == emp_id); if (isExist) { long id = db.Employee_Personal_Detail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); return(RedirectToAction("Details", "EmployeePersonalDetail", new { id })); } } //ViewBag.Caste = new SelectList(db.CastMasters, "CastCode", "CastName"); ViewBag.Caste = new SelectList(""); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name"); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM"); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value"); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName"); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName"); return(View(obj)); }
public ActionResult Create([Bind(Include = "ID,Gender,DOB,Category,IdentityMark1,IdentityMark2,Religion,Citizenship,Caste,Race,MarraigeStatus,MarraigeDate,NoOfChild,NoOfDependents,AadharNo,SIN,AKA,MilitaryService,BirthCity,Note,Hobbies,MilitaryServiceDetail,EMP_ID")] Employee_Personal_Detail employee_Personal_Detail) { long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "emp") { ModelState.Remove("EMP_ID"); employee_Personal_Detail.EMP_ID = emp_id; } if (ModelState.IsValid) { //Date checking if (employee_Personal_Detail.DOB >= employee_Personal_Detail.MarraigeDate) { ViewBag.success = "DOB must ne smaller than Marraige Date!"; ViewBag.Caste = new SelectList(db.CastMaster.Where(x => x.ReligionID == employee_Personal_Detail.Religion), "CastCode", "CastName"); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name"); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM"); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value"); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName"); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(employee_Personal_Detail)); } bool isValid = db.Employee_Personal_Detail.Any(x => x.EMP_ID == employee_Personal_Detail.EMP_ID); if (!isValid) { db.Employee_Personal_Detail.Add(employee_Personal_Detail); db.SaveChanges(); ViewBag.success = "Your Personal Details is Successfully Added!"; ModelState.Clear(); if (role == "emp") { long id = db.Employee_Personal_Detail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); return(RedirectToAction("Details", "EmployeePersonalDetail", new { id })); } //ViewBag.Caste = new SelectList(""); //ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name"); //ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM"); //ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value"); //ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName"); //ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName"); if (role == "admin") { ViewBag.Role = "admin"; return(RedirectToAction("Create", "EmployeeContactDetails", new { ID = employee_Personal_Detail.EMP_ID })); } //return View(); } else { ViewBag.error = "Sorry! This record is already exist!"; ViewBag.Caste = new SelectList(db.CastMaster.Where(x => x.ReligionID == employee_Personal_Detail.Religion), "CastCode", "CastName"); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name"); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM"); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value"); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName"); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(employee_Personal_Detail)); } } ViewBag.Caste = new SelectList(""); ViewBag.Category = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name"); ViewBag.Citizenship = new SelectList(db.HRMS_EMP_CITIZENSHIP_MS, "CitizenShip_ID", "CitizenShip_Country_NM"); ViewBag.Gender = new SelectList(db.HRMS_EMP_GENDER_MS, "Gender_ID", "Gender_Value"); ViewBag.MarraigeStatus = new SelectList(db.MaritalMaster, "MaritalID", "MaritalName"); ViewBag.Religion = new SelectList(db.ReligionMaster, "ReligionID", "ReligionName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(employee_Personal_Detail)); }