Exemple #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;
                }
            }
        }
Exemple #2
0
        public PCMDiversionViewModel GetDivesionFromDBDivbyId(int Diversion_Id)
        {
            PCMDiversionViewModel vm = new PCMDiversionViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Diversion act = db.PCM_Diversion.Find(Diversion_Id);

                    if (act != null)
                    {
                        vm.Diversion_Id       = act.Diversion_Id;
                        vm.Source_Referral_Id = act.Source_Referral_Id;
                        if (act.Source_Referral_Id > 0)
                        {
                            vm.RefSourcedesrciption = db.apl_PCM_Referral_Source.Find(act.Source_Referral_Id).Description;
                        }

                        vm.Programme_Id = act.Programme_id;
                        if (act.Programme_id > 0)
                        {
                            vm.DesrciptionDivesionPrograme = db.apl_Programmes.Find(act.Programme_id).Programme_Name;
                        }

                        vm.No_Modules                 = act.No_Modules;
                        vm.Programme_Level_Id         = act.Programme_Level_Id;
                        vm.Modified_By                = act.Modified_By;
                        vm.Date_Modified              = act.Date_Modified;
                        vm.Court_Type_Id              = act.Court_Type_Id;
                        vm.PCM_Preliminary_Id         = act.PCM_Preliminary_Id;
                        vm.Formal_Courtcome_Id        = act.Formal_Courtcome_Id;
                        vm.Childrens_Court_Outcome_Id = act.Childrens_Court_Outcome_Id;
                    }
                }
                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);
            }
        }
Exemple #3
0
        public void DiversionAdd(PCMDiversionViewModel vm, int userid, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Diversion DiversionNew = db.PCM_Diversion.Find(Intake_Assessment_Id);
                    if (DiversionNew != null)
                    {
                        DiversionNew.Intake_Assessment_Id      = vm.Intake_Assessment_Id;
                        DiversionNew.Source_Referral_Id        = vm.Source_Referral;
                        DiversionNew.Province_Id               = vm.Province_Id;
                        DiversionNew.Service_Provider_Category = vm.Service_Provider_Category;
                        DiversionNew.Services_Provider_Id      = vm.Services_Provider_Id;
                        DiversionNew.Programme_id              = vm.Programme_Id;
                        DiversionNew.No_Modules         = vm.No_Modules;
                        DiversionNew.Programme_Level_Id = vm.Programme_Level_Id;
                        DiversionNew.Created_By         = userid;
                        DiversionNew.Date_Created       = DateTime.Now;
                        DiversionNew.Modified_By        = userid;
                        DiversionNew.Date_Modified      = 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 a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
        }
Exemple #4
0
        public void PCM_Diversion_SPAddnew(PCMDiversionViewModel vm, int Intake_Assessment_Id, int userid)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Diversion _SP = new PCM_Diversion();
                    _SP.Intake_Assessment_Id       = Intake_Assessment_Id;
                    _SP.Source_Referral_Id         = vm.Source_Referral;
                    _SP.Programme_Level_Id         = vm.Programme_Level_Id;
                    _SP.Programme_AgeGroup_Id      = vm.Programme_AgeGroup_Id;
                    _SP.Programme_id               = vm.Programme_Id;
                    _SP.Created_By                 = userid;
                    _SP.Childrens_Court_Outcome_Id = vm.Childrens_Court_Outcome_Id;
                    _SP.PCM_Preliminary_Id         = vm.PCM_Preliminary_Id;
                    _SP.Formal_Courtcome_Id        = vm.Formal_Courtcome_Id;
                    _SP.Court_Type_Id              = vm.Court_Type_Id;
                    _SP.Diversion_Id               = vm.Diversion_Id;

                    _SP.Date_Created = DateTime.Now;
                    _SP.Created_By   = userid;

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