示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        public ActionResult Get(int id)
        {
            if (!_dogService.DogFactExists(id))
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "The dog could not be found"));
            }

            return(Ok(_dogService.GetById(id)));
        }
示例#4
0
        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));
        }
示例#6
0
        public async Task <IActionResult> GetById(int id)
        {
            var response = await dogService.GetById(id);

            return(Ok(response));
        }