Example #1
0
        public void UpdateOutcome(PCMFCRViewModel vm, int FormalCourtOutcome_Id, int assID)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_FCR_Outcome pp = db.PCM_FCR_Outcome.Find(FormalCourtOutcome_Id);
                    pp.CourtDate              = vm.CourtDate;
                    pp.Remand                 = vm.Remand;
                    pp.RemandReason           = vm.RemandReason;
                    pp.NextCourtDate          = vm.NextCourtDate;
                    pp.CourtOutcome           = vm.CourtOutcome;
                    pp.FormalCaseStatus_Id    = vm.FormalCaseStatus_Id;
                    pp.Placement_Type_Id      = vm.Placement_Type_Id;
                    pp.Recommendation_Type_Id = vm.PCM_Recommendation_Id;

                    db.SaveChanges();


                    PCM_HB_Supervision exist1 = db.PCM_HB_Supervision.OrderByDescending(x => x.HomeBasedSupervision_Id).FirstOrDefault(x => x.FormalCourtOutcome_Id == FormalCourtOutcome_Id);


                    //PCM_HB_Supervision exist1 = db.PCM_HB_Supervision.OrderByDescending.Where(x => x.FormalCourtOutcome_Id == FormalCourtOutcome_Id).FirstOrDefault();

                    if (pp.Placement_Type_Id == 187 && exist1 == null)

                    {
                        PCM_HB_Supervision newhomebase = new PCM_HB_Supervision();

                        newhomebase.FormalCourtOutcome_Id = pp.FormalCourtOutcome_Id;
                        newhomebase.Intake_Assessment_Id  = assID;
                        newhomebase.Court_Type_Id         = 2;

                        db.PCM_HB_Supervision.Add(newhomebase);
                        db.SaveChanges();
                    }

                    PCM_Diversion exist12 = db.PCM_Diversion.OrderByDescending(x => x.Diversion_Id).FirstOrDefault(x => x.Formal_Courtcome_Id == FormalCourtOutcome_Id);
                    //PCM_Diversion exist12 = db.PCM_Diversion.Where(x => x.Formal_Courtcome_Id == FormalCourtOutcome_Id).FirstOrDefault();

                    if (pp.Recommendation_Type_Id == 1 && exist12 == null)

                    {
                        PCM_Diversion newhomebase = new PCM_Diversion();

                        newhomebase.Formal_Courtcome_Id  = pp.FormalCourtOutcome_Id;
                        newhomebase.Intake_Assessment_Id = assID;
                        newhomebase.Court_Type_Id        = 2;

                        db.PCM_Diversion.Add(newhomebase);
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #2
0
        public void UpdateHBS(PCMHBSViewModel vm, int userId, int HomeBasedSupervision_Id, int assID)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_Supervision newCC = db.PCM_HB_Supervision.Find(HomeBasedSupervision_Id);

                    newCC.HomeBasedSupervision_Id = HomeBasedSupervision_Id;
                    newCC.Conditions_Id           = vm.Conditions_Id;
                    newCC.Visitation_Period       = vm.Visitation_Period;
                    newCC.Number_of_Visit         = vm.Number_of_Visit;
                    newCC.Placement_Date          = vm.Placement_Date;
                    newCC.HBS_Supervisor_Id       = vm.HBS_Supervisor_Id;
                    newCC.Placement_Confirmed     = vm.Placement_Confirmed;

                    db.SaveChanges();



                    PCM_HB_CourtOutcome exist2 = db.PCM_HB_CourtOutcome.Where(x => x.HomeBasedSupervision_Id == HomeBasedSupervision_Id).SingleOrDefault();
                    if (exist2 == null)
                    {
                        PCM_HB_CourtOutcome newHB = new PCM_HB_CourtOutcome();

                        newHB.Intake_Assessment_Id    = assID;
                        newHB.HomeBasedSupervision_Id = vm.HomeBasedSupervision_Id;


                        db.PCM_HB_CourtOutcome.Add(newHB);
                        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;
                }
            }
        }
Example #3
0
        /// <summary>
        /// to edit PCM_HB_Supervision
        /// to get HomeBasedSupervision_Id
        /// </summary>
        /// <param name="HomeBasedSupervision_Id"></param>
        /// <returns></returns>
        public PCMHBSViewModel EditHBS(int HomeBasedSupervision_Id)
        {
            PCMHBSViewModel vm = new PCMHBSViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    int?id = (from c in db.PCM_HB_Supervision
                              where (c.HomeBasedSupervision_Id == HomeBasedSupervision_Id)
                              select c.HomeBasedSupervision_Id).FirstOrDefault();

                    PCM_HB_Supervision s = db.PCM_HB_Supervision.Find(id);
                    if (s != null)
                    {
                        vm.HomeBasedSupervision_Id = db.PCM_HB_Supervision.Find(s.HomeBasedSupervision_Id).HomeBasedSupervision_Id;
                        vm.Intake_Assessment_Id    = s.Intake_Assessment_Id;
                        vm.Compliance_Id           = s.Conditions_Id;
                        vm.Visitation_Period       = s.Visitation_Period;
                        vm.Number_of_Visit         = s.Number_of_Visit;
                        vm.Placement_Date          = s.Placement_Date;
                        vm.HBS_Supervisor_Id       = s.HBS_Supervisor_Id;
                        vm.Placement_Confirmed     = s.Placement_Confirmed;

                        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(vm);
        }
Example #4
0
        public void CreateHBS(PCMHBSViewModel vm, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_Supervision newHB = new PCM_HB_Supervision();

                    newHB.Intake_Assessment_Id = Intake_Assessment_Id;
                    newHB.Conditions_Id        = vm.Conditions_Id;
                    newHB.Visitation_Period    = vm.Visitation_Period;
                    newHB.Number_of_Visit      = vm.Number_of_Visit;
                    newHB.Placement_Date       = vm.Placement_Date;
                    newHB.HBS_Supervisor_Id    = vm.HBS_Supervisor_Id;
                    newHB.Placement_Confirmed  = vm.Placement_Confirmed;

                    db.PCM_HB_Supervision.Add(newHB);
                    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;
                }
            }
        }
Example #5
0
        public PCMPreliminaryViewModel Update(PCMPreliminaryViewModel pre, int userId, int PcmPreliID, int AssID)
        {
            PCMPreliminaryViewModel vm = new PCMPreliminaryViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Preliminary_Details fc = db.PCM_Preliminary_Details.Find(PcmPreliID);
                    if (fc != null)
                    {
                        fc.PCM_Recommendation_Id        = pre.PCM_Recommendation_Id;
                        fc.PCM_Preliminary_Status_Id    = pre.Preliminary_Status_Id;
                        fc.Placement_Pre_Recommended_Id = pre.Placement_Type_Id;
                        fc.PCM_Preliminary_Date         = pre.PCM_Preliminary_Date;
                        fc.PCM_Outcome_Reason           = pre.PCM_Outcome_Reason;

                        fc.Date_Modified = pre.Date_Modified;
                        fc.Modified_By   = pre.Modified_By;
                        fc.Date_Created  = pre.Date_Created;
                        db.SaveChanges();

                        PCM_HB_Supervision exist1 = db.PCM_HB_Supervision.OrderByDescending(x => x.HomeBasedSupervision_Id).FirstOrDefault(x => x.PCM_Preliminary_Id == PcmPreliID);

                        //PCM_HB_Supervision exist1 = db.PCM_HB_Supervision.Where(x => x.PCM_Preliminary_Id == PcmPreliID).SingleOrDefault();
                        if (fc.Placement_Pre_Recommended_Id == 187 && exist1 == null)
                        {
                            PCM_HB_Supervision add = new PCM_HB_Supervision();


                            add.PCM_Preliminary_Id   = PcmPreliID;
                            add.Intake_Assessment_Id = AssID;
                            add.Court_Type_Id        = 1;

                            db.PCM_HB_Supervision.Add(add);
                            db.SaveChanges();
                        }

                        PCM_Diversion exist12 = db.PCM_Diversion.OrderByDescending(x => x.Diversion_Id).FirstOrDefault(x => x.PCM_Preliminary_Id == PcmPreliID);

                        if (fc.PCM_Preliminary_Id == 1 && exist12 == null)

                        {
                            PCM_Diversion newhomebase = new PCM_Diversion();

                            newhomebase.PCM_Preliminary_Id   = fc.PCM_Preliminary_Id;
                            newhomebase.Intake_Assessment_Id = AssID;
                            newhomebase.Court_Type_Id        = 1;

                            db.PCM_Diversion.Add(newhomebase);
                            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(vm);
            }
        }
Example #6
0
        public void CreatePCMChildrensCourtOutcome(PCMChildrensCourtViewModel vm, int RecomendationID, int Outcome_Id, int assID)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Childrens_Court_Outcome newOutcome = db.PCM_Childrens_Court_Outcome.Find(Outcome_Id);
                    newOutcome.Court_Date             = vm.Court_Date;
                    newOutcome.Remand                 = vm.Remand;
                    newOutcome.Reason_Remand          = vm.Reason_Remand;
                    newOutcome.Next_Court_Date        = vm.Next_Court_Date;
                    newOutcome.Court_Outcome          = vm.Court_Outcome;
                    newOutcome.Placement_Type_Id      = vm.Type_Of_Placement_Id;
                    newOutcome.Recommendation_Type_Id = vm.Recommendation_Type_Id;
                    newOutcome.Court_Case_Status_Id   = vm.Court_Case_Status_Id;


                    db.SaveChanges();



                    PCM_HB_Supervision exist1 = db.PCM_HB_Supervision.OrderByDescending(x => x.HomeBasedSupervision_Id).FirstOrDefault(x => x.Outcome_Id == Outcome_Id);
                    if (newOutcome.Placement_Type_Id == 187 && exist1 == null)

                    {
                        PCM_HB_Supervision newhomebase = new PCM_HB_Supervision();

                        newhomebase.Outcome_Id           = newOutcome.Outcome_Id;
                        newhomebase.Intake_Assessment_Id = assID;
                        newhomebase.Court_Type_Id        = 3;

                        db.PCM_HB_Supervision.Add(newhomebase);
                        db.SaveChanges();
                    }

                    PCM_Diversion exist12 = db.PCM_Diversion.OrderByDescending(x => x.Diversion_Id).FirstOrDefault(x => x.Childrens_Court_Outcome_Id == Outcome_Id);
                    if (newOutcome.Recommendation_Type_Id == 1 && exist12 == null)

                    {
                        PCM_Diversion newhomebase = new PCM_Diversion();

                        newhomebase.Childrens_Court_Outcome_Id = newOutcome.Outcome_Id;
                        newhomebase.Intake_Assessment_Id       = assID;
                        newhomebase.Court_Type_Id = 3;

                        db.PCM_Diversion.Add(newhomebase);
                        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;
                }
            }
        }