Ejemplo n.º 1
0
        public void CreatePCMChildrensCourt(PCMChildrensCourtViewModel vm, int RecomendationID, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Childrens_Court newCC = new PCM_Childrens_Court();
                    newCC.PCM_Recommendation_Id = RecomendationID;
                    newCC.Intake_Assessment_Id  = Intake_Assessment_Id;
                    newCC.Court_Expiry_Date     = vm.Court_Expiry_Date;
                    newCC.Prelim_Enquiry_Date   = vm.Prelim_Enquiry_Date;
                    newCC.Child_Need_Care       = vm.Child_Need_Care;
                    newCC.Substance_Abuse_Treat = vm.Substance_Abuse_Treat;
                    //newCC.Substance_Abuse_Treat = subAbuseTreat;
                    newCC.Referral_Date         = vm.Referral_Date;
                    newCC.Alternative_Placement = vm.Alternative_Placement;
                    newCC.Case_Manager          = vm.Case_Manager;
                    newCC.Service_Provider      = vm.Service_Provider;

                    db.PCM_Childrens_Court.Add(newCC);
                    db.SaveChanges();

                    PCM_Childrens_Court_Outcome newOutcome = new PCM_Childrens_Court_Outcome();
                    newOutcome.Outcome_Id           = vm.Outcome_Id;
                    newOutcome.Intake_Assessment_Id = Intake_Assessment_Id;


                    newOutcome.Children_Court_Id = newCC.Children_Court_Id;

                    db.PCM_Childrens_Court_Outcome.Add(newOutcome);
                    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;
                }
            }
        }
Ejemplo n.º 2
0
        public PCMChildrensCourtViewModel GetPCMChildrensCourtEditDetails(int ChildrenCourtId)
        {
            PCMChildrensCourtViewModel vm = new PCMChildrensCourtViewModel();

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

                    PCM_Childrens_Court cc = db.PCM_Childrens_Court.Find(id);
                    if (cc != null)
                    {
                        vm.Children_Court_Id     = db.PCM_Childrens_Court.Find(cc.Children_Court_Id).Children_Court_Id;
                        vm.PCM_Recommendation_Id = cc.PCM_Recommendation_Id;
                        vm.Court_Expiry_Date     = cc.Court_Expiry_Date;
                        vm.Prelim_Enquiry_Date   = cc.Prelim_Enquiry_Date;
                        vm.Child_Need_Care       = cc.Child_Need_Care;
                        vm.Substance_Abuse_Treat = cc.Substance_Abuse_Treat;
                        vm.Referral_Date         = cc.Referral_Date;
                        vm.Intake_Assessment_Id  = cc.Intake_Assessment_Id;

                        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);
            }
        }
Ejemplo n.º 3
0
        public PCMChildrensCourtViewModel GetCCDetails(int Id)
        {
            PCMChildrensCourtViewModel vm = new PCMChildrensCourtViewModel();
            SDIIS_DatabaseEntities     db = new SDIIS_DatabaseEntities();

            //var cc = db.PCM_Childrens_Court.Find(Id);
            PCM_Childrens_Court model = db.PCM_Childrens_Court.Where(x => x.Intake_Assessment_Id == Id).SingleOrDefault();

            vm.Children_Court_Id   = model.Children_Court_Id;
            vm.Court_Expiry_Date   = model.Court_Expiry_Date;
            vm.Prelim_Enquiry_Date = model.Prelim_Enquiry_Date;
            //vm.Child_Need_Care = model.Child_Need_Care;
            vm.Alternative_Placement = model.Alternative_Placement;
            //vm.kidAddress = gd.kidAddress;

            return(vm);
        }
Ejemplo n.º 4
0
        public void UpdatePCMChildrensCourt(PCMChildrensCourtViewModel vm, int Children_Court_Id, int userid)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Childrens_Court newCC = db.PCM_Childrens_Court.Find(Children_Court_Id);

                    newCC.Court_Expiry_Date     = vm.Court_Expiry_Date;
                    newCC.Prelim_Enquiry_Date   = vm.Prelim_Enquiry_Date;
                    newCC.Child_Need_Care       = vm.Child_Need_Care;
                    newCC.Substance_Abuse_Treat = vm.Substance_Abuse_Treat;
                    newCC.Referral_Date         = vm.Referral_Date;
                    newCC.Alternative_Placement = vm.Alternative_Placement;
                    newCC.Case_Manager          = vm.Case_Manager;
                    newCC.Service_Provider      = vm.Service_Provider;
                    vm.Modified_By   = userid;
                    vm.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;
                }
            }
        }