コード例 #1
0
        public ResponseDTO Create(RefTypeDTO DTO)
        {
            RefType entity = this.mapper.Map <RefType>(DTO);

            this.unitOfWork.Repository <RefType>().Create(entity);
            return(CreateResponse <RefTypeDTO> .Return(DTO, "Create"));
        }
コード例 #2
0
        public ResponseDTO <RefTypeDTO> Delete(RefTypeDTO DTO)
        {
            var entity = unitOfWork.Repository <RefType>().GetByKey(DTO.Id);

            unitOfWork.Repository <RefType>().Delete(entity);
            unitOfWork.EndTransaction();
            return(CreateResponse <RefTypeDTO> .Return(DTO, "Delete"));
        }
コード例 #3
0
        public ResponseDTO <RefTypeDTO> Update(RefTypeDTO DTO)
        {
            var entity = unitOfWork.Repository <RefType>().GetByKey(DTO.Id);

            entity.Update(DTO.Status, DTO.Name, DTO.IsActive, DTO.UpdateDate);
            unitOfWork.Repository <RefType>().Update(entity);
            unitOfWork.EndTransaction();
            return(CreateResponse <RefTypeDTO> .Return(DTO, "Update"));
        }
コード例 #4
0
        public ResponseDTO <AddRefTypeResponseDTO> Create(AddRefTypeRequestDTO DTO)
        {
            var entity = new RefType(DTO.Status, DTO.InsertDate, DTO.Name, DTO.IsActive);

            if (DTO.Parent.Id > 0)
            {
                entity.SetParent(this.unitOfWork.Repository <RefType>().GetByKey(DTO.Parent.Id));
            }

            unitOfWork.Repository <RefType>().Create(entity);
            unitOfWork.EndTransaction();
            return(CreateResponse <AddRefTypeResponseDTO> .Return(Mapper.Map(DTO, new AddRefTypeResponseDTO()), "Create"));
        }
コード例 #5
0
        public ResponseListDTO <RefTypeDTO> GetByParent(long parentId)
        {
            IEnumerable <RefType> entity;

            if (parentId > 0)
            {
                entity = unitOfWork.Repository <RefType>().Query().Filter(x => x.Parent.Id == parentId).Get();
            }
            else
            {
                entity = unitOfWork.Repository <RefType>().Query().Filter(x => x.Parent.Id == null).Get();
            }

            unitOfWork.EndTransaction();

            //List<RefTypeDTO> response = new List<RefTypeDTO>();
            return(CreateResponse <RefTypeDTO> .Return(Mapper.Map <RefType[], IEnumerable <RefTypeDTO> >(entity.ToArray()), "GetByParent"));
        }