コード例 #1
0
 public ActionResult <IEnumerable <Car> > GetCarsByUser()
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_cs.GetByUserId(userId)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #2
0
 public ActionResult <IEnumerable <Car> > GetCarsByUser()
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("You must be logged in to get your cars!.");
         }
         string userId = user.Value;
         return(Ok(_cs.GetByUserId(userId)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }