예제 #1
0
 public ActionResult <Car> Create([FromBody] Car newCar)
 {
     try
     {
         newCar.UserId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_cs.Create(newCar)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
예제 #2
0
 public ActionResult <Car> Create([FromBody] Car newCar)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Must be logged in to create.");
         }
         newCar.UserId = user.Value;
         return(Ok(_cs.Create(newCar)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }