Esempio n. 1
0
        /// <summary>
        /// 获取部门/院系信息
        /// </summary>
        /// <param name="id">部门/院系编号</param>
        /// <param name="context">数据库连接上下文对象</param>
        /// <returns></returns>
        public async Task <DepartmentEditViewModel> GetDepartmentAsync(long id, ApplicationDbContext context)
        {
            var webModel = new DepartmentEditViewModel();

            try
            {
                var model = await SchoolRepository.GetAsync(id, context);

                webModel.Id           = model.Id.ToString();
                webModel.IsBranch     = (EnumType.Branch)(model.IsBranch ? 1 : 0);
                webModel.Address      = model.Address;
                webModel.Email        = model.Email;
                webModel.Introduction = model.Introduction;
                webModel.IsEnabled    = (EnumType.Enable)(model.IsEnabled ? 1 : 0);
                webModel.Name         = model.Name;
                webModel.QQ           = model.QQ;
                webModel.Tel          = model.Tel;
                webModel.Wechat       = model.Wechat;
                webModel.Weibo        = model.Weibo;
            }
            catch (Exception ex)
            {
                _logger.LogError("获取部门/院系数据失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }