Пример #1
0
        public void DeleteWorkGroup(WorkGroupDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentException("DTO参数为空!");
            }

            var current = _workGroupRepository.Get(dto.Id);
            if (current != null)
            {
                _workGroupRepository.Remove(current);
            }
        }
Пример #2
0
        public void UpdateWorkGroup(WorkGroupDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentException("DTO参数为空!");
            }

            var persist = _workGroupRepository.Get(dto.Id);
            var current = MaterialWorkGroupFromDTO(dto);
            _workGroupRepository.Merge(persist, current);
            // 处理工作组成员
            var dtoMembers = dto.Members;
            var members = persist.Members;
            DataHelper.DetailHandle(dtoMembers.ToArray(), members.ToArray(),
                c => c.Id, p => p.Id,
                i => persist.Members.Add(MaterialMemberFromDTO(i)),
                UpdateMember,
                d => _workGroupRepository.RemoveMember(d)
                );
        }
Пример #3
0
 /// <summary>
 ///     将DTO转为实质的数据实体
 /// </summary>
 /// <param name="dto">DTO</param>
 /// <returns>实质数据实体</returns>
 private WorkGroup MaterialWorkGroupFromDTO(WorkGroupDTO dto)
 {
     var current = WorkGroupFactory.CreateWorkGroup(dto.Name);
     current.ChangeCurrentIdentity(dto.Id);
     return current;
 }
Пример #4
0
        public void InsertWorkGroup(WorkGroupDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentException("DTO参数为空!");
            }

            var current = MaterialWorkGroupFromDTO(dto);
            // 处理工作组成员
            dto.Members.ToList().ForEach(m => current.Members.Add(MaterialMemberFromDTO(m)));

            _workGroupRepository.Add(current);
        }