Exemple #1
0
 public ActionResult <House> Create([FromBody] House newHouse)
 {
     try
     {
         return(Ok(_service.Create(newHouse)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <IEnumerable <House> > Create([FromBody] House newHouse)
 {
     try
     {
         return(Ok(_housesService.Create(newHouse)));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
 public ActionResult <House> Create([FromBody] House newHouse)
 {
     try
     {
         House house = _ds.Create(newHouse);
         return(Ok(house));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
 public ActionResult <House> Create([FromBody] House newHouse)
 {
     try
     {
         newHouse.UserId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_hs.Create(newHouse)));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
 public ActionResult <House> Create([FromBody] House newHouse)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("login to post new stuff dude!");
         }
         newHouse.UserId = user.Value;
         return(Ok(_hs.Create(newHouse)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
 public ActionResult <House> Create([FromBody] House newHouse)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("You must be logged in to make a House, yo.");
         }
         newHouse.UserId = user.Value;
         return(Ok(_service.Create(newHouse)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }