public List <DTO.StudyProductDTO> GetAllProducts()
        {
            IProductRepository repo = new ProductRepository();
            var result  = repo.GetProducts();
            var result1 = ConverterDTO.ListStudyProducttoStudyProductDTO(result.ToList());

            return(result1);
        }
        public DTO.StudyProductDTO GetProduct(int ProductId)
        {
            IProductRepository repo = new ProductRepository();
            var result  = repo.GetProduct(ProductId);
            var result1 = ConverterDTO.StudyProducttoStudyProductDTO(result);

            return(result1);
        }
        public bool AddProduct(DTO.StudyProductDTO Product)
        {
            IProductRepository repo = new ProductRepository();
            StudyProduct       p    = ConverterDTO.StudyProductDTOtoStudyProduct(Product);

            p.Id = 9;
            var result = repo.AddProduct(p);

            return(result);
        }
Пример #4
0
        public DepartmentDTOOutSingle GetDepartmentByID(int id)
        {
            logger.Info("Accessing department repo, getdepartmentbyid, departments service");
            Department department = db.DepartmentsRepository.GetByID(id);

            if (department == null)
            {
                throw new DepartmentNotFound($"Departments with {id} doesent exists");
            }

            DepartmentDTOOutSingle departmentDTO = new DepartmentDTOOutSingle()
            {
                Department = new DepartmentDTOStudent()
                {
                    Id             = department.Id,
                    DepartmentName = department.DepartmentName
                },
                Grade    = ConverterDTO.SimpleDTOConverter <GradeDTO>(department.Grades),
                Subjects = department.Grades.Subjects.Select(x => ConverterDTO.SimpleDTOConverter <SubjectDTO>(x))
            };

            return(departmentDTO);
        }