public List <Criminal> SearchCriminal(Criminal CriminalSearch) { using (PoliceSystemEntities db = new PoliceSystemEntities()) { if (CriminalSearch != null) { var searchcriminal = db.Criminals.Where(a => a.Cnic == CriminalSearch.Cnic || a.Name == CriminalSearch.Name).ToList(); return(searchcriminal); } else { return(null); } } }
public bool AddCriminal(Criminal addCriminal) { using (PoliceSystemEntities db = new PoliceSystemEntities()) { if (addCriminal != null) { db.Criminals.Add(addCriminal); db.SaveChanges(); return(true); } else { return(false); } } }
public IHttpActionResult Login(Account login) { using (PoliceSystemEntities db = new PoliceSystemEntities()) { var userlogin = db.Accounts.FirstOrDefault(a => a.Name == login.Email && a.Pass == login.Pass); if (userlogin != null) { System.Web.HttpContext.Current.Session["Id"] = userlogin.Id.ToString(); System.Web.HttpContext.Current.Session["Email"] = userlogin.Email.ToString(); return(CheckUser()); } return(InternalServerError()); } }
public bool CreateAccount(Account createAccount) { if (createAccount != null) { using (PoliceSystemEntities db = new PoliceSystemEntities()) { db.Accounts.Add(createAccount); db.SaveChanges(); return(true); } } else { return(false); } }
public bool RemoveCriminal(Criminal removeCriminal) { if (removeCriminal != null) { using (PoliceSystemEntities db = new PoliceSystemEntities()) { var RemoveCriminalsList = db.Criminals.Where(a => a.Id == removeCriminal.Id); foreach (var DeleteCriminal in RemoveCriminalsList) { db.Criminals.Remove(DeleteCriminal); db.SaveChanges(); } return(true); } } else { return(false); } }