public IEnumerable <ReportDto> GetAll() { var reports = _mapper.Map <IEnumerable <ReportEntity>, IEnumerable <ReportDto> >(_reportRepository.GetAll()); foreach (var report in reports) { report.Dog = _dogService.Get(report.DogId); } return(reports); }
public JsonResult GetDog(string Dogname) { try { Dog Dog = _dogService.Get(Dogname); return(Json(Dog, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.Error(ex); return(Json("Couldn't get dog", JsonRequestBehavior.AllowGet)); } }
public IActionResult GetDog([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dog = _dogService.Get(id); if (dog == null) { return(NotFound()); } return(Ok(dog)); }
public async Task<IActionResult> Get(long id) { var response = await dogService.Get(id); var apiResponse = new ApiResponse<DogDto>( response.IsDone, response.Message, mapper.Map<Dog, DogDto>(response.Data), null ); string file = response.Data.Picture.Picture; apiResponse.Data.Type = "image"; apiResponse.Data.Extension = file.Substring(file.LastIndexOf('.') + 1); return Ok(apiResponse); }