public Alleged_Offender CreateAllegedOffender(int?incidentId, int?personId, bool isKnownOffender, int?childRelationshipTypeId, int?occupationId, string passport, string driversLicense, int?workAddressId, string whereAbouts) { var dbContext = new SDIIS_DatabaseEntities(); var allegedOffender = new Alleged_Offender() { Incident_Id = incidentId, Person_Id = personId, Is_Known_Offender = isKnownOffender, Child_Relationship_Type_Id = childRelationshipTypeId, Occupation_Id = occupationId, Passport = passport, Drivers_License = driversLicense, Work_Address_Id = workAddressId, Whereabouts = whereAbouts }; try { var newAllegedOffender = dbContext.Alleged_Offenders.Add(allegedOffender); dbContext.SaveChanges(); return(newAllegedOffender); } catch (Exception) { return(null); } }
public List <CPR_Incident> GetListOfIncidents(bool showInActive, bool showDeleted, Alleged_Offender allegedOffender) { List <CPR_Incident> incidents; var dbContext = new SDIIS_DatabaseEntities(); try { var incidentList = (from i in dbContext.CPR_Incidents where i.Is_Active.Equals(true) || i.Is_Active.Equals(!showInActive) where i.Is_Deleted.Equals(false) || i.Is_Deleted.Equals(showDeleted) where i.Alleged_Offenders.Contains(allegedOffender) select i).ToList(); incidents = (from i in incidentList select i).ToList(); } catch (Exception) { return(null); } return(incidents); }