예제 #1
0
        /// <summary>
        /// 修改一个EmployeeOtherInfo
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Update(EmployeeOtherInfo input)
        {
            if (input.Id != Guid.Empty)
            {
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.Id);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
                }
                var user = UserManager.Users.FirstOrDefault(x => x.Id == input.UserId);
                if (user == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该用户不存在。");
                }
                dbmodel.UserId = input.UserId;
                dbmodel.Remark = input.Remark;

                await _repository.UpdateAsync(dbmodel);
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
        }
예제 #2
0
        /// <summary>
        /// 添加一个EmployeeOtherInfo
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Create(CreateEmployeeOtherInfoInput input)
        {
            if (string.IsNullOrEmpty(input.Remark))
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "请填写内容。");
            }
            var user = UserManager.Users.FirstOrDefault(x => x.Id == input.UserId);

            if (user == null)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该用户不存在。");
            }
            var newmodel = new EmployeeOtherInfo()
            {
                UserId = input.UserId,
                Remark = input.Remark
            };
            await _repository.InsertAsync(newmodel);
        }