Beispiel #1
0
 public IActionResult GetByUserId([FromRoute] string userId)
 {
     try {
         return(Ok(_repo.GetByUserId(userId)));
     } catch (Exception error) {
         return(BadRequest(error.Message));
     }
 }
Beispiel #2
0
 public ActionResult <Keep> GetByUserId()
 {
     try
     {
         var id = HttpContext.User.FindFirstValue("Id");
         return(Ok(_repo.GetByUserId(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
Beispiel #3
0
        // Get keeps by User ID
        public List <Keep> GetKeepsByUserId(string id)
        {
            // Get the userId from the users's erver session as more-secure alternative to passing it in from the front-end:
            var user = HttpContext.User;

            if (user.Identity.Name != null)
            {
                var sessionId = user.Identity.Name;
                return(_keepsRepo.GetByUserId(sessionId));
            }
            return(null);

            // Alternative -- Use the userId passed in from the front end as a route parameter:
            // return _keepsRepo.GetByUserId(id);
        }
        public IEnumerable <Keep> Get()
        {
            var userId = HttpContext.User.Identity.Name;

            return(_repo.GetByUserId(userId));
        }