public ActionResult Login(FormCollection fc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); if (ModelState.IsValid) { string username = fc["email"]; string password = fc["password"]; try { tbl_User tb = _db.tbl_User.Single(u => u.Email == username && u.Password == password); if (tb != null) { Session.Add("Username", username); return(RedirectToAction("Index", "Home")); } } catch (Exception) { ViewBag.Message = "Username or Password does not match"; } } ModelState.AddModelError("", "Please write first name."); return(View()); }
public ActionResult AssignUserRoles() { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tb = _db.tbl_User; List <UserModelClass> ulst = new List <UserModelClass>(); foreach (tbl_User item in tb) { UserModelClass umc = new UserModelClass(); umc.UserID = item.UserID; umc.Name = item.Name; umc.Address = item.Address; umc.Contact = item.Contact; umc.Role = item.Role; ulst.Add(umc); } return(View(ulst)); } List <UserModelClass> ll = new List <UserModelClass>(); ViewBag.Message = "Please Contact Admin"; return(View(ll)); }
public ActionResult AssignCase() { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tblc = _db.tbl_Case; List <CaseModelClass> lstc = new List <CaseModelClass>(); foreach (tbl_Case item in tblc) { CaseModelClass cmc = new CaseModelClass(); cmc.CaseName = item.CaseName; cmc.CaseType = item.CaseType; cmc.CaseDetails = item.CaseDetails; cmc.CaseID = item.CaseID; cmc.Lawyer = item.Lawyer; lstc.Add(cmc); } return(View(lstc)); } ViewBag.Message = "Please Contact Admin"; List <CaseModelClass> lst = new List <CaseModelClass>(); return(View(lst)); }
public ActionResult AddLawyer(FormCollection fc) { try { tbl_Lawyer l = new tbl_Lawyer(); l.Name = fc["name"]; l.Address = fc["address"]; l.Age = Int32.Parse(fc["age"]); l.Degree = fc["degree"]; l.Specialty = fc["specialty"]; l.Contact = fc["contact"]; l.IsActive = Boolean.Parse("True"); l.DateJoined = DateTime.Now.ToShortDateString(); JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); _db.tbl_Lawyer.Add(l); _db.SaveChanges(); return(RedirectToAction("Lawyer")); } catch (Exception) { ViewBag.Message = "Some Error Occured!!"; return(View()); } }
// // GET: /Application/ public ActionResult Lawyer() { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var lawyers = _db.tbl_Lawyer; List <LawyerModelClass> lawlst = new List <LawyerModelClass>(); foreach (tbl_Lawyer lawyer in lawyers) { LawyerModelClass lmc = new LawyerModelClass(); lmc.LawyerID = lawyer.LawyerID; lmc.Name = lawyer.Name; lmc.Degree = lawyer.Degree; lmc.Address = lawyer.Address; lmc.Contact = lawyer.Contact; lmc.CasesSolved = lawyer.CasesSolved; lmc.Specialty = lawyer.Specialty; lmc.DateJoined = lawyer.DateJoined; lmc.Age = lawyer.Age; lawlst.Add(lmc); } return(View(lawlst)); }
public ActionResult ViewCase() { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var User = Session["Username"]; tbl_User tb = _db.tbl_User.Single(u => u.Email == User); var userid = tb.UserID; var lawname = tb.Name; var tblc = _db.tbl_Case.Where(u => u.UserID == userid || u.Lawyer == lawname); List <CaseModelClass> lstc = new List <CaseModelClass>(); foreach (tbl_Case item in tblc) { CaseModelClass cmc = new CaseModelClass(); cmc.CaseName = item.CaseName; cmc.CaseType = item.CaseType; cmc.CaseDetails = item.CaseDetails; cmc.CaseID = item.CaseID; cmc.Lawyer = item.Lawyer; lstc.Add(cmc); } return(View(lstc)); }
public ActionResult EditLawyer(LawyerModelClass lmc) { try { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Lawyer l = _db.tbl_Lawyer.Single(u => u.LawyerID == lmc.LawyerID); l.Name = lmc.Name; l.Address = lmc.Address; l.Age = lmc.Age; l.Degree = lmc.Degree; l.Specialty = lmc.Specialty; l.Contact = lmc.Contact; l.IsActive = Boolean.Parse("True"); l.DateJoined = DateTime.Now.ToShortDateString(); _db.SaveChanges(); ViewBag.Message = "Edited Successfully"; return(RedirectToAction("Lawyer")); } catch (Exception) { ViewBag.Message = "Some Error Occured!!"; return(View()); } }
public ActionResult DeleteLawyer(int id) { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Lawyer l = _db.tbl_Lawyer.Single(u => u.LawyerID == id); LawyerModelClass lmc = new LawyerModelClass(); lmc.LawyerID = l.LawyerID; lmc.Name = l.Name; lmc.Degree = l.Degree; lmc.Specialty = l.Specialty; lmc.Age = l.Age; lmc.Contact = l.Contact; lmc.Address = l.Address; return(View(lmc)); } return(RedirectToAction("Error")); }
public JsonResult GetAllUsers() { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var users = _db.tbl_Case.ToList(); return(Json(users, JsonRequestBehavior.AllowGet)); }
public ActionResult AddRole(UserModelClass umc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_User tb = _db.tbl_User.Single(u => u.UserID == umc.UserID); tb.Role = umc.Role; _db.SaveChanges(); return(RedirectToAction("AssignUserRoles")); }
public ActionResult EditCase(CaseModelClass cmc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Case tb = _db.tbl_Case.Single(u => u.CaseID == cmc.CaseID); tb.CaseName = cmc.CaseName; tb.CaseType = cmc.CaseType; tb.CaseDetails = cmc.CaseDetails; _db.SaveChanges(); return(View("Cases")); }
public ActionResult AddRole(int id) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tb = _db.tbl_User.Single(u => u.UserID == id); UserModelClass umc = new UserModelClass(); umc.UserID = tb.UserID; umc.Name = tb.Name; return(View(umc)); }
public ActionResult EditCase(int id) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Case tb = _db.tbl_Case.Single(u => u.CaseID == id); CaseModelClass cmc = new CaseModelClass(); cmc.CaseID = tb.CaseID; cmc.CaseName = tb.CaseName; cmc.CaseType = tb.CaseType; cmc.CaseDetails = tb.CaseDetails; return(View(cmc)); }
public ActionResult AddLawyer() { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { return(View()); } return(RedirectToAction("Error")); }
public ActionResult Assign(CaseModelClass cmc, FormCollection fc) { if (cmc.Lawyer == "Choose Lawyer") { ViewBag.Message = "Please select Lawyer"; } JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Case tb = _db.tbl_Case.Single(u => u.CaseID == cmc.CaseID); int lid = Int32.Parse(fc["Lawyer"]); tbl_Lawyer tbl = _db.tbl_Lawyer.Single(v => v.LawyerID == lid); tb.Lawyer = tbl.Name; _db.SaveChanges(); return(RedirectToAction("AssignCase")); }
public ActionResult AddCase(FormCollection fc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var User = Session["Username"]; tbl_User tb = _db.tbl_User.Single(u => u.Email == User); tbl_Case tbl = new tbl_Case(); tbl.CaseName = fc["casename"]; tbl.CaseDetails = fc["casedetails"]; tbl.CaseType = fc["casetype"]; tbl.UserID = tb.UserID; _db.tbl_Case.Add(tbl); _db.SaveChanges(); return(RedirectToAction("ViewCase")); }
public ActionResult EditAccount(UserModelClass umc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_User tb = _db.tbl_User.Single(u => u.UserID == umc.UserID); tb.Name = umc.Name; tb.UserID = umc.UserID; tb.Name = umc.Name; tb.Address = umc.Address; tb.Contact = umc.Contact; tb.Email = umc.Email; tb.Username = umc.Username; tb.Password = umc.Password; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AccountDetails() { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tb = _db.tbl_User.Single(u => u.Email == email); UserModelClass umc = new UserModelClass(); umc.UserID = tb.UserID; umc.Name = tb.Name; umc.Address = tb.Address; umc.Contact = tb.Contact; umc.Email = tb.Email; umc.Username = tb.Username; umc.Password = tb.Password; return(View(umc)); }
public ActionResult Assign(int id) { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); tbl_Case tb = db.tbl_Case.Single(u => u.CaseID == id); CaseModelClass cmc = new CaseModelClass(); cmc.CaseName = tb.CaseName; cmc.CaseID = tb.CaseID; cmc.CaseType = tb.CaseType; cmc.CaseDetails = tb.CaseDetails; cmc.Lawyer = tb.Lawyer; JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); ViewBag.Lawyers = _db.tbl_Lawyer; return(View(cmc)); }
public ActionResult LawyerDetails(int id) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Lawyer l = _db.tbl_Lawyer.Single(u => u.LawyerID == id); LawyerModelClass lmc = new LawyerModelClass(); lmc.LawyerID = l.LawyerID; lmc.Name = l.Name; lmc.Degree = l.Degree; lmc.Specialty = l.Specialty; lmc.Age = l.Age; lmc.Contact = l.Contact; lmc.CasesSolved = l.CasesSolved; lmc.Address = l.Address; lmc.DateJoined = l.DateJoined; return(View(lmc)); }
public ActionResult DeleteLawyer(LawyerModelClass lmc) { try { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_Lawyer l = _db.tbl_Lawyer.Single(u => u.LawyerID == lmc.LawyerID); _db.tbl_Lawyer.Remove(l); _db.SaveChanges(); ViewBag.Message = "Deleted Successfully"; return(RedirectToAction("Lawyer")); } catch (Exception) { ViewBag.Message = "Some Error Occured!!"; return(View()); } }
public ActionResult CreateAccount(FormCollection fc) { if (ModelState.IsValid) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_User umc = new tbl_User(); umc.Name = fc["name"]; umc.Email = fc["email"]; umc.Contact = fc["contact"]; umc.Address = fc["address"]; umc.Username = fc["username"]; umc.Password = fc["password"]; umc.AddedDate = DateTime.Now.ToShortDateString(); umc.IsActive = bool.Parse("True"); _db.tbl_User.Add(umc); _db.SaveChanges(); return(RedirectToAction("Login", "Home")); } return(View()); }