Exemple #1
0
        // GET: HealthInfo/Details/5
        public ActionResult <BaseViewModel> DeleteHealthRegister(HealthInfoDeleteViewModel healthInfoDeleteViewModel)
        {
            BaseViewModel baseViewModel = new BaseViewModel();

            healthRegisterService.DeleteHealthRegisterInfo(healthInfoDeleteViewModel);
            baseViewModel.Message      = "删除成功";
            baseViewModel.ResponseCode = 200;
            return(Ok(baseViewModel));
        }
        /// <summary>
        /// 删除登记健康信息
        /// </summary>
        /// <param name="healthInfoDeleteViewModel"></param>
        public void DeleteHealthRegisterInfo(HealthInfoDeleteViewModel healthInfoDeleteViewModel)
        {
            healthRegisterRepository.DelByList(healthInfoDeleteViewModel.DeleteList);

            for (int i = 0; i < healthInfoDeleteViewModel.DeleteList.Count; i++)
            {
                var facultystaff = facultystaffInfoRepository.getbyID(healthInfoDeleteViewModel.DeleteList[i]); //查询白绑定的基础信息
                var studentInfo  = studentInfoRepository.getbyID(healthInfoDeleteViewModel.DeleteList[i]);
                if (facultystaff != null)                                                                       //不为空复制键值
                {
                    facultystaff.StudentRegisterHeath_InfoId = null;
                    facultystaffInfoRepository.Update(facultystaff);
                }
                if (studentInfo != null)
                {
                    studentInfo.StudentRegisterHeath_InfoId = null;
                    studentInfoRepository.Update(studentInfo);
                }
            }
            healthRegisterRepository.SaveChanges();
        }