Beispiel #1
0
        public void UpdateReferalToCouncelling(PCMReferralsViewModel vm, int userId, int Referrals_Councelling_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Referral_Counselling ass = db.PCM_Referral_Counselling.Find(Referrals_Councelling_Id);

                    //cases.PCM_Case_Id = cas
                    ass.Referrals_Id     = vm.Referrals_Id;
                    ass.Type_Referral_Id = vm.Type_Referral_Id;
                    ass.Period_From      = vm.Period_From;
                    ass.Period           = vm.Period_To;
                    ass.Child_Progress   = vm.Progress_Report;
                    ass.Modified_By      = userId;
                    ass.Date_Modified    = DateTime.Now;


                    db.SaveChanges();
                }
                catch
                {
                }
            }
        }
Beispiel #2
0
        public void SaveReferralsData(PCMReferralsViewModel vM, int userid, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Referrals ReferralNew = new PCM_Referrals();
                    ReferralNew.Client_Employee_Details_ID = vM.Client_Employee_Details_ID;
                    ReferralNew.Intake_Assessment_Id       = Intake_Assessment_Id;
                    ReferralNew.Type_Referral_Id           = vM.Type_Referral_Id;
                    ReferralNew.theClerk      = vM.theClerk;
                    ReferralNew.theParticular = vM.theParticular;
                    ReferralNew.Created_By    = userid;
                    ReferralNew.Date_Created  = DateTime.Now;

                    db.PCM_Referrals.Add(ReferralNew);
                    db.SaveChanges();


                    if (ReferralNew.Type_Referral_Id == 1)
                    {
                        PCM_Referral_To_Court nu = new PCM_Referral_To_Court();
                        nu.Referrals_Id         = ReferralNew.Referrals_Id;
                        nu.Intake_Assessment_Id = Intake_Assessment_Id;
                        nu.Type_Referral_Id     = vM.Type_Referral_Id;
                        nu.Created_By           = userid;
                        nu.Date_Created         = DateTime.Now;

                        db.PCM_Referral_To_Court.Add(nu);
                        db.SaveChanges();
                    }
                    else if (ReferralNew.Type_Referral_Id == 2)
                    {
                        PCM_Referral_To_Programme nu = new PCM_Referral_To_Programme();
                        nu.Referrals_Id         = ReferralNew.Referrals_Id;
                        nu.Intake_Assessment_Id = Intake_Assessment_Id;
                        nu.Type_Referral_Id     = vM.Type_Referral_Id;
                        nu.Created_By           = userid;
                        nu.Date_Created         = DateTime.Now;

                        db.PCM_Referral_To_Programme.Add(nu);
                        db.SaveChanges();
                    }
                    else if (ReferralNew.Type_Referral_Id == 3)
                    {
                        PCM_Referral_Counselling nu = new PCM_Referral_Counselling();
                        nu.Referrals_Id         = ReferralNew.Referrals_Id;
                        nu.Intake_Assessment_Id = Intake_Assessment_Id;
                        nu.Type_Referral_Id     = vM.Type_Referral_Id;
                        nu.Created_By           = userid;
                        nu.Date_Created         = DateTime.Now;

                        db.PCM_Referral_Counselling.Add(nu);
                        db.SaveChanges();
                    }
                    else if (ReferralNew.Type_Referral_Id == 4)
                    {
                        PCM_Referral_SocilaWorker nu = new PCM_Referral_SocilaWorker();
                        nu.Referrals_Id         = ReferralNew.Referrals_Id;
                        nu.Intake_Assessment_Id = Intake_Assessment_Id;
                        nu.Type_Referral_Id     = vM.Type_Referral_Id;
                        nu.Created_By           = userid;
                        nu.Date_Created         = DateTime.Now;

                        db.PCM_Referral_SocilaWorker.Add(nu);
                        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;
                }
            }
        }
Beispiel #3
0
        public void UpdateReferralsData(PCMReferralsViewModel prVM, int id, int userid, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Referrals rr = db.PCM_Referrals.Find(id);
                    rr.PCM_Case_Id = prVM.PCM_Case_Id;
                    rr.Client_Employee_Details_ID = prVM.Client_Employee_Details_ID;
                    rr.theClerk         = prVM.theClerk;
                    rr.theParticular    = prVM.theParticular;
                    rr.Type_Referral_Id = prVM.Type_Referral_Id;
                    rr.Modified_By      = userid;
                    rr.Date_Modified    = DateTime.Now;

                    db.SaveChanges();



                    if (rr.Type_Referral_Id == 1)
                    {
                        PCM_Referral_To_Court c = db.PCM_Referral_To_Court.Where(x => x.Referrals_Id == id && x.Type_Referral_Id == rr.Type_Referral_Id).SingleOrDefault();

                        if (c == null)
                        {
                            PCM_Referral_To_Court nu = new PCM_Referral_To_Court();
                            nu.Referrals_Id         = rr.Referrals_Id;
                            nu.Intake_Assessment_Id = Intake_Assessment_Id;
                            nu.Type_Referral_Id     = prVM.Type_Referral_Id;
                            nu.Created_By           = userid;
                            nu.Date_Created         = DateTime.Now;

                            db.PCM_Referral_To_Court.Add(nu);
                            db.SaveChanges();
                        }
                    }
                    else if (rr.Type_Referral_Id == 2)
                    {
                        PCM_Referral_To_Programme c = db.PCM_Referral_To_Programme.Where(x => x.Referrals_Id == id && x.Type_Referral_Id == rr.Type_Referral_Id).SingleOrDefault();

                        if (c == null)
                        {
                            PCM_Referral_To_Programme nu = new PCM_Referral_To_Programme();
                            nu.Referrals_Id         = rr.Referrals_Id;
                            nu.Intake_Assessment_Id = Intake_Assessment_Id;
                            nu.Type_Referral_Id     = prVM.Type_Referral_Id;
                            nu.Created_By           = userid;
                            nu.Date_Created         = DateTime.Now;

                            db.PCM_Referral_To_Programme.Add(nu);
                            db.SaveChanges();
                        }
                    }
                    else if (rr.Type_Referral_Id == 3)
                    {
                        PCM_Referral_Counselling c = db.PCM_Referral_Counselling.Where(x => x.Referrals_Id == id && x.Type_Referral_Id == rr.Type_Referral_Id).SingleOrDefault();

                        if (c == null)
                        {
                            PCM_Referral_Counselling nu = new PCM_Referral_Counselling();
                            nu.Referrals_Id         = rr.Referrals_Id;
                            nu.Intake_Assessment_Id = Intake_Assessment_Id;
                            nu.Type_Referral_Id     = prVM.Type_Referral_Id;
                            nu.Created_By           = userid;
                            nu.Date_Created         = DateTime.Now;

                            db.PCM_Referral_Counselling.Add(nu);
                            db.SaveChanges();
                        }
                    }
                    else if (rr.Type_Referral_Id == 4)
                    {
                        PCM_Referral_SocilaWorker c = db.PCM_Referral_SocilaWorker.Where(x => x.Referrals_Id == id && x.Type_Referral_Id == rr.Type_Referral_Id).SingleOrDefault();

                        if (c == null)
                        {
                            PCM_Referral_SocilaWorker nu = new PCM_Referral_SocilaWorker();
                            nu.Referrals_Id         = rr.Referrals_Id;
                            nu.Intake_Assessment_Id = Intake_Assessment_Id;
                            nu.Type_Referral_Id     = prVM.Type_Referral_Id;
                            nu.Created_By           = userid;
                            nu.Date_Created         = DateTime.Now;

                            db.PCM_Referral_SocilaWorker.Add(nu);
                            db.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }