Esempio n. 1
0
        /// <summary>
        /// 根据医院代码更新医院信息
        /// </summary>
        /// <param name="hospital"></param>
        /// <returns></returns>
        public Task <bool> UpdateHospitalByCodeAsync(Hospital hospital)
        {
            var oldHospital = _hospitalRepository.FindByClause(h => h.code == hospital.code);

            if (oldHospital is null)
            {
                return(Task.FromResult(false));
            }
            var result = Submit(() =>
            {
                hospital.code = oldHospital.code;
                hospital.id   = oldHospital.id;
                _hospitalRepository.Update(hospital);
                _hospitalTagRepository.Delete(ht => ht.hospitalCode == hospital.code);
                foreach (var tag in hospital.Tags)
                {
                    _hospitalTagRepository.Insert(new HospitalTag
                    {
                        hospitalCode = hospital.code,
                        tagId        = tag.id
                    });
                }
            });

            return(Task.FromResult(result));
        }