public VEPInboxVM CheckAssementExistance() { // initializing view model VEPInboxVM newCase = new VEPInboxVM(); // initialise connection using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { try { //Check assessment from intake assessment not in Adoption work list var List = (from List1 in db.Intake_Assessments where !(from List2 in db.VEP_WorkList select List2.Intake_Assessment_Id).Contains(List1.Intake_Assessment_Id) where List1.Problem_Sub_Category_Id == 19 select List1).ToList(); //ADOPT_Case_WorkList act = db.ADOPT_Case_WorkList.Find(worlistid); foreach (var item in List) { if (List != null) { //insert values not in Work list for List VEP_WorkList act = new VEP_WorkList(); act.Intake_Assessment_Id = item.Intake_Assessment_Id; //act.Allocated_By =item.Assessed_By_Id; //act.VEP_Record_Status_Id = 1; //act.Allocated_To = item.Case_Manager_Id; //act.Date_Allocated = item.Date_Allocated; db.VEP_WorkList.Add(act); db.SaveChanges(); } } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } return(newCase); } }
public List <VEPInboxVM> ExistingWorklist() { List <VEPInboxVM> kg = new List <VEPInboxVM>(); SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities(); var kList = (from i in db.Intake_Assessments //join v in db.VEP_WorkList //on i.Intake_Assessment_Id equals v.Intake_Assessment_Id join c in db.Clients on i.Client_Id equals c.Client_Id join p in db.Persons on c.Person_Id equals p.Person_Id join g in db.Genders on p.Gender_Id equals g.Gender_Id //where (i.Problem_Sub_Category_Id == 19) select new { p.Person_Id, p.First_Name, p.Last_Name, p.Identification_Number, p.Gender, p.Age, i.Problem_Sub_Category_Id, i.Assessment_Date, i.Date_Allocated, i.Created_By, c.Client_Id, g.Description }).ToList(); foreach (var item in kList) { VEPInboxVM objK = new VEPInboxVM(); objK.Person_Id = item.Person_Id; objK.First_Name = item.First_Name; objK.Last_Name = item.Last_Name; objK.Identification_Number = item.Identification_Number; objK.Description = item.Description; objK.Age = item.Age; objK.Problem_Sub_Category_Id = item.Problem_Sub_Category_Id; objK.Assessment_Date = item.Assessment_Date; objK.Date_Allocated = item.Date_Allocated; objK.Created_By = item.Created_By; //objK.Client_Id = item.Client_Id; kg.Add(objK); } return(kg); }
public void UpdateWorkVEPListCase(VEPInboxVM list, int AssId) { // initialise connection using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities()) { try { // Accept New case on work list var editlist = (from i in db.VEP_WorkList where i.Intake_Assessment_Id == (AssId) select i.Status_Id).FirstOrDefault(); VEP_WorkList edit = db.VEP_WorkList.Find(editlist); edit.Intake_Assessment_Id = AssId; //edit.VEP_Record_Status_Id = 2; //edit.Accepted_By = list.Case_Manager_Id; edit.Date_Accepted = DateTime.Now; db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); raise = new InvalidOperationException(message, raise); } } throw raise; } } }