示例#1
0
        public void UpdateReferralsData(PCMReferralsViewModel prVM, int id, int userid)
        {
            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();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#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;
                }
            }
        }
示例#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;
                }
            }
        }