예제 #1
0
        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);
            }
        }
예제 #2
0
        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;
                }
            }
        }