public ActionResult <DogDTO> Get(int id) { var dog = dogService.GetById(id); if (dog == null) { return(NotFound()); } var dogDTO = mapper.Map <DogDTO>(dog); return(Ok(dogDTO)); }
public ActionResult Details(int?id) { /*if (Session["AdminEmail"] == null) * { * return RedirectToAction("Login", "Admin"); * }*/ if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dog dog = dogService.GetById(id); return(View(dog)); }
public ActionResult Get(int id) { if (!_dogService.DogFactExists(id)) { return(StatusCode(StatusCodes.Status400BadRequest, "The dog could not be found")); } return(Ok(_dogService.GetById(id))); }
public ActionResult <DogResponse> GetById(int id) { //admins can get any dog //if (id != Account.Id && Account.Role != Role.Admin) // return Unauthorized(new { message = "Unauthorized" }); var dog = _dogService.GetById(id); return(Ok(dog)); }
public ActionResult <DogResponse> GetById(int id) { // users can get their own account and admins can get any account if (id != Account.Id && Account.Role != Role.Admin) { return(Unauthorized(new { message = "Unauthorized" })); } var account = _dogService.GetById(id); return(Ok(account)); }
public async Task <IActionResult> GetById(int id) { var response = await dogService.GetById(id); return(Ok(response)); }