示例#1
0
        public async Task Create(CreateEmployeeTrainingSystemInput input)
        {
            if ((input.PortsIds == null || !input.PortsIds.Any()) && input.Type == TrainingSystemType.Post)
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "请至少选择一个部门岗位!");
            }
            var newmodel = new EmployeeTrainingSystem()
            {
                Title    = input.Title,
                Contents = input.Contents,
                Type     = input.Type
            };

            await _repository.InsertAsync(newmodel);

            if (input.PortsIds != null && input.PortsIds.Any())
            {
                input.PortsIds.ForEach(async x =>
                {
                    await _postsRepository.InsertAsync(new EmployeeTrainingSystemUnitPosts()
                    {
                        SysId   = newmodel.Id,
                        PortsId = x
                    });
                });
            }
        }
示例#2
0
        public async Task Update(EmployeeTrainingSystem 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, "该数据不存在。");
                }
                dbmodel.Title    = input.Title;
                dbmodel.Contents = input.Contents;
                await _repository.UpdateAsync(dbmodel);
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
        }