Example #1
0
        public ActionResult <CaseReadDto> GetCaseById(Guid id)
        {
            var caseItem = _repository.GetCaseById(id);

            // If found, return Model mapped as DTO object
            if (caseItem != null)
            {
                return(Ok(_mapper.Map <CaseReadDto>(caseItem)));
            }
            return(NotFound());
        }
        public ActionResult <CaseTechniqueCreateDto> CreateCaseTechnique(CaseTechniqueCreateDto caseTechniqueCreateDto)
        {
            // Map Dto to Model
            var caseTechniqueModel = _mapper.Map <CaseTechnique>(caseTechniqueCreateDto);

            var checkCaseId = _caserepository.GetCaseById(caseTechniqueModel.CaseId);

            if (checkCaseId == null)
            {
                return(NotFound("CaseId invalid"));
            }
            var checkTechniqueId = _techniquerepository.GetTechniqueById(caseTechniqueModel.TechniqueId);

            if (checkTechniqueId == null)
            {
                return(NotFound("TechniqueId invalid"));
            }

            _repository.CreateCaseTechnique(caseTechniqueModel);
            _repository.SaveChanges();

            var caseTechniqueReadDto = _mapper.Map <CaseTechniqueReadDto>(caseTechniqueModel);

            // CreatedAtRoute creates 201 created with specified values.
            return(CreatedAtRoute(nameof(GetCaseTechniqueById), new { Id = caseTechniqueReadDto.Id }, caseTechniqueReadDto));
        }
Example #3
0
        public void ThenGetCaseBy(int caseId)
        {
            //   ScenarioContext.Current.Pending();
            caseRepo = new CaseRepoImpl();
            myCase   = caseRepo.GetCaseById(caseId);
            CasesController controller = new CasesController();
            var             case2      = controller.Get(myCase.ID);

            Assert.AreEqual(case2.ID, myCase.ID, "id not match.");
        }
 public Case Get(int id)
 {
     return(_caseRepo.GetCaseById(id));
 }