public IList <TechnicalInspectionGridViewModel> GetAll()
        {
            _unitOfWork.BeginTransaction();

            var allInspections          = _technicalInspectionRepository.GetAll();
            var allInspectionsViewModel = allInspections.Select(x => x.MapToGridViewModel()).ToList();

            _unitOfWork.Commit();

            return(allInspectionsViewModel);
        }
Ejemplo n.º 2
0
        public IList <TechnicalInspectionViewModel> GetInspections(Guid id)
        {
            _unitOfWork.BeginTransaction();

            var mechanic = _mechanicRepository.GetById(id);

            if (mechanic == null)
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.MechanicException.NOT_FOUND);
            }

            var inspections         = _technicalInspectionRepository.GetAll().Where(x => x.Mechanic.Id == mechanic.Id);
            var inspectionViewModel = inspections.Select(x => x.MapToViewModel()).ToList();

            _unitOfWork.Commit();
            return(inspectionViewModel);
        }