public List <vw_CaseDefectsData> GetVictimsByCaseID(int CaseID, int SessionID) { var victims = (from _case in DataContext.Cases_Cases join _session in DataContext.Cases_CaseSessions on _case.ID equals _session.CaseID join _victim in DataContext.Cases_CaseVictims on _case.ID equals _victim.CaseID join _personVictim in DataContext.Configurations_Persons on _victim.PersonID equals _personVictim.ID join _victimsSessionLog in DataContext.Cases_VictimsSessionsLog on _victim.ID equals _victimsSessionLog.VictimID into VSLog from _vslog in VSLog.DefaultIfEmpty() join _PresenceStatus in DataContext.Configurations_Lookups on _vslog.PresenceStatusID equals _PresenceStatus.ID into PStatus from _ps in PStatus.DefaultIfEmpty() where _case.ID == CaseID && _session.ID == SessionID && _case.IsDeleted != true select new vw_CaseDefectsData { ID = _victim.ID, PersonID = _victim.PersonID, Name = _personVictim.FullName, NationalID = _personVictim.NationalID, DefectType = PartyTypes.Victim, IsCivilRightProsecutor = _victim.IsCivilRightProsecutor, Presence = _vslog == null ? 0 :(PresenceStatus)_vslog.PresenceStatusID, JobName = _personVictim.JobTitle, NationalityType = _personVictim.NationalityID, PassportNumber = _personVictim.PassportNumber, Birthdate = _personVictim.Birthdate, Order = _victim.Order, Address = _personVictim.Address, Nationality = _personVictim.Configurations_Lookups.Name, }).ToList(); return(victims); }
public List <vw_CaseDefectsData> GetDefendantsByCaseID(int CaseID, int SessionID) { var defendants = (from _case in DataContext.Cases_Cases join _session in DataContext.Cases_CaseSessions on _case.ID equals _session.CaseID join _defendant in DataContext.Cases_CaseDefendants on _case.ID equals _defendant.CaseID join _defendantCaseLog in DataContext.Cases_DefendatnsCaseLog on _defendant.ID equals _defendantCaseLog.DefendantID join _personDefendant in DataContext.Configurations_Persons on _defendant.PersonID equals _personDefendant.ID join Look in DataContext.Configurations_Lookups on _personDefendant.NationalityID equals Look.ID join _defendantsSessionLog in DataContext.Cases_DefendatnsSessionsLog on _defendant.ID equals _defendantsSessionLog.DefendantID into DSLog from _dslog in DSLog.DefaultIfEmpty() join _PresenceStatus in DataContext.Configurations_Lookups on _dslog.PresenceStatusID equals _PresenceStatus.ID into PStatus from _ps in PStatus.DefaultIfEmpty() join _PoliceStationStatus in DataContext.Configurations_Lookups on _defendantCaseLog.PoliceStationStatusID equals _PoliceStationStatus.ID where _case.ID == CaseID && _case.IsDeleted != true && _session.ID == SessionID && !_defendantCaseLog.ToDate.HasValue select new vw_CaseDefectsData { ID = (int)_defendant.ID, PersonID = _defendant.PersonID, Name = _personDefendant.FullName, NationalID = _personDefendant.NationalID, DefectType = PartyTypes.Defendant, IsCivilRightProsecutor = _defendant.IsCivilRightProsecutor, Presence = _dslog == null ? 0 : (PresenceStatus)_dslog.PresenceStatusID, Status = _defendantCaseLog.PoliceStationStatusID, JobName = _personDefendant.JobTitle, NationalityType = _personDefendant.NationalityID, PassportNumber = _personDefendant.PassportNumber, Birthdate = _personDefendant.Birthdate, Order = _defendant.Order, Nationality = Look.Name, Address = _personDefendant.Address, // Age = DateTime.Now.Year - (DateTime)_personDefendant.Year }).Distinct().ToList(); return(defendants); }