public void DeleteRecord(string String, int id) { int UseThisId = (from t in dbContext.VEP_VictimizationType where t.VictimizationType == String select t.Id).FirstOrDefault(); VEP_VictimizationTypeDetails Obj = (from j in dbContext.VEP_VictimizationTypeDetails where j.Case_Id == id && j.VictimizationType == UseThisId select j).FirstOrDefault(); dbContext.VEP_VictimizationTypeDetails.Remove(Obj); dbContext.SaveChanges(); }
public int Create(int selected_VictimizationId, int CaseId) { var dbContext = new SDIIS_DatabaseEntities(); try { var victimRecord = new VEP_VictimizationTypeDetails(); victimRecord.Case_Id = CaseId; victimRecord.VictimizationType = selected_VictimizationId; dbContext.VEP_VictimizationTypeDetails.Add(victimRecord); dbContext.SaveChanges(); return(victimRecord.Case_Id); } catch (Exception ex) { var Test = ex.Message; return(-1); } }
public void UpdateIncidentInformation(VictimRecord Obj, int Id) { if (Obj.VictimTypeSelectedList != null) { for (int i = 0; i < Obj.VictimTypeSelectedList.Count(); ++i) { int newInt = Obj.VictimTypeSelectedList[i]; int Test = (from a in dbContext.VEP_VictimizationTypeDetails where a.Case_Id == Id && a.VictimizationType == newInt select a.Id).FirstOrDefault(); if (Test == 0) { VEP_VictimizationTypeDetails SubObj = new VEP_VictimizationTypeDetails(); SubObj.Case_Id = Id; SubObj.VictimizationType = newInt; SubObj.IsItSelected = true; dbContext.VEP_VictimizationTypeDetails.Add(SubObj); dbContext.SaveChanges(); } if (Test > 0) { VEP_VictimizationTypeDetails SubObj = (from p in dbContext.VEP_VictimizationTypeDetails where p.Case_Id == Id && p.VictimizationType == newInt select p).FirstOrDefault(); SubObj.Case_Id = Id; SubObj.VictimizationType = newInt; SubObj.IsItSelected = true; dbContext.SaveChanges(); } } } int CheckIfExistVEP_IncidentInformation = (from s in dbContext.VEP_IncidentInformation where s.Caseid == Id select s.IncidentID).FirstOrDefault(); if (CheckIfExistVEP_IncidentInformation == 0) { VEP_IncidentInformation VCModel = new VEP_IncidentInformation(); VCModel.Caseid = Id; VCModel.Incident_Details = Obj.IncidentInformation.IncidentDetails; (VCModel.Victimisation_Type) = Convert.ToString(Obj.IncidentInformation.VictimisationType); VCModel.PlaceofIncident = Obj.IncidentInformation.PlaceOfIncident; VCModel.TypeofSettlement = Convert.ToString(Obj.IncidentInformation.VEP_SettlementType); VCModel.DateofIncident = Obj.IncidentInformation.DateOfIncident; VCModel.DateofReporting = Obj.IncidentInformation.DateOfReporting; VCModel.PoliceCaseNumber = Obj.IncidentInformation.PoliceCaseNumber; VCModel.PoliceOBnumber = Obj.IncidentInformation.PoliceOBnumber; //VCModel.TypeofSettlement = dbContext.VEP_SettlementType.Find(Obj.IncidentInformation.SettlementId).Settlement; if (Obj.IncidentInformation.KnowPerpetrator == 1) { VCModel.DoyouknowtheallegedPerpetrator = "Yes"; dbContext.SaveChanges(); } else { VCModel.DoyouknowtheallegedPerpetrator = "No"; dbContext.SaveChanges(); } if (Obj.IncidentInformation.PerpFamilyMemeber == 1) { VCModel.Perpetratorrelatedtoyou = "Yes"; dbContext.SaveChanges(); } else { VCModel.Perpetratorrelatedtoyou = "No"; dbContext.SaveChanges(); } if (Obj.IncidentInformation.PerpCommunityMember == 1) { VCModel.immediatecommunity = "Yes"; dbContext.SaveChanges(); } else { VCModel.immediatecommunity = "No"; dbContext.SaveChanges(); } if (Obj.IncidentInformation.ReportedToPolice == 1) { VCModel.ReportedtothePolice = "Yes"; dbContext.SaveChanges(); } else { VCModel.ReportedtothePolice = "No"; dbContext.SaveChanges(); } //VCModel.immediatecommunity = Obj.IncidentInformation.PerpCommunityMember; //VCModel.ReportedtothePolice = Obj.IncidentInformation.ReportedToPolice; VCModel.PoliceCaseNumber = Obj.IncidentInformation.PoliceCaseNumber; VCModel.PoliceOBnumber = Obj.IncidentInformation.PoliceOBnumber; dbContext.VEP_IncidentInformation.Add(VCModel); dbContext.SaveChanges(); } else { VEP_IncidentInformation VCModel = (from k in dbContext.VEP_IncidentInformation where k.Caseid == Id select k).FirstOrDefault(); VCModel.Caseid = Id; VCModel.Incident_Details = Obj.IncidentInformation.IncidentDetails; VCModel.Victimisation_Type = Convert.ToString(Obj.IncidentInformation.VictimisationType); VCModel.PlaceofIncident = Obj.IncidentInformation.PlaceOfIncident; VCModel.DateofIncident = Obj.IncidentInformation.DateOfIncident; VCModel.DateofReporting = Obj.IncidentInformation.DateOfReporting; VCModel.DateofReporting = Obj.IncidentInformation.DateOfReporting; //VCModel.TypeofSettlement = dbContext.VEP_SettlementType.Find(Obj.IncidentInformation.SettlementId).Settlement; if (Obj.IncidentInformation.KnowPerpetrator == 1) { VCModel.DoyouknowtheallegedPerpetrator = "Yes"; dbContext.SaveChanges(); } else { VCModel.DoyouknowtheallegedPerpetrator = "No"; dbContext.SaveChanges(); } if (Obj.IncidentInformation.PerpFamilyMemeber == 1) { VCModel.Perpetratorrelatedtoyou = "Yes"; dbContext.SaveChanges(); } else { VCModel.Perpetratorrelatedtoyou = "No"; dbContext.SaveChanges(); } //VCModel.immediatecommunity = Obj.IncidentInformation.; //VCModel.ReportedtothePolice = Obj.IncidentInformation.ReportedToPolice; VCModel.PoliceCaseNumber = Obj.IncidentInformation.PoliceCaseNumber; VCModel.PoliceOBnumber = Obj.IncidentInformation.PoliceOBnumber; dbContext.SaveChanges(); } }