public ResponseDTO Create(RefTypeDTO DTO) { RefType entity = this.mapper.Map <RefType>(DTO); this.unitOfWork.Repository <RefType>().Create(entity); return(CreateResponse <RefTypeDTO> .Return(DTO, "Create")); }
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")); }
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")); }
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")); }
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")); }