Exemplo n.º 1
0
        public void CreatePCMConditionsDeatils(PCMHBSViewModel cases, int HomebaseId, int Condition_Id, int userId)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HBS_Condition newCase = new PCM_HBS_Condition();

                    newCase.HomeBasedSupervision_Id = HomebaseId;
                    newCase.Condition_Id            = Condition_Id;
                    newCase.Created_By   = userId;
                    newCase.Date_Created = DateTime.Now;
                    db.PCM_HBS_Condition.Add(newCase);

                    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;
                }
            }
        }
Exemplo n.º 2
0
 public void DeleteConditionRecord(int id)
 {
     using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
     {
         PCM_HBS_Condition Obj = (from j in db.PCM_HBS_Condition
                                  where j.HB_Condition_Id == id
                                  select j).FirstOrDefault();
         db.PCM_HBS_Condition.Remove(Obj);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="Intake_Assessment_Id"></param>
        public void CreateCondition(PCMHBSViewModel vm, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HBS_Condition newCondition = new PCM_HBS_Condition();

                    //string School_Attendance = true;

                    newCondition.Intake_Assessment_Id = Intake_Assessment_Id;
                    newCondition.School_Attendance    = vm.School_Attendance;
                    newCondition.Family_Time          = vm.Family_Time;
                    newCondition.Good_Behaviour       = vm.Good_Behaviour;
                    newCondition.Reporting            = vm.Reporting;
                    newCondition.Supervision          = vm.Supervision;

                    db.PCM_HBS_Condition.Add(newCondition);
                    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 = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
        }