Пример #1
0
        public virtual async Task <IServiceResponse <U> > GetByIdAsync(int id)
        {
            var entity = await ExecuteWithoutTransactionAsync <T>
                             (async() => await _unitOfWork.Repository <T>().GetByIdAsync(id, _idbHelper.GetPrimaryKeyAutoGenerated <T>()));

            var dto = _mapper.Map <U>(entity);

            return(new ServiceResponse <U>(entity != null, ServiceResponseMessage.GetById_Success <T>(), dto));
        }
Пример #2
0
        public virtual async Task <IServiceResponse <IEnumerable <U> > > GetRangeAsync(IEnumerable <int> Ids)
        {
            if (Ids == null || !Ids.Any())
            {
                return(new ServiceResponse <IEnumerable <U> >(false, ServiceResponseMessage.GetById_Success <IEnumerable <T> >()));
            }

            var response = await ExecuteWithoutTransactionAsync(async() => await _unitOfWork.Repository <T>().GetByIdRangeAsync(Ids));

            return(new ServiceResponse <IEnumerable <U> >(true, ServiceResponseMessage.Get_Success <IEnumerable <U> >(), _mapper.Map <IEnumerable <U> >(response)));
        }