public ActionResult <Recipe> Create([FromBody] Recipe newRec) { try { return(Ok(_rs.Create(newRec))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <Recipe> Create([FromBody] Recipe newRecipe) { try { return(Ok(_service.Create(newRecipe))); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public async Task <ActionResult <Recipe> > Create([FromBody] Recipe newRecipe) { try { Account userInfo = await HttpContext.GetUserInfoAsync <Account>(); _acctService.GetOrCreateAccount(userInfo); newRecipe.CreatorId = userInfo.Id; Recipe recipe = _rService.Create(newRecipe); return(Ok(recipe)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <ActionResult <Recipe> > Create([FromBody] Recipe newRecipe) { try { // TODO[epic=Auth] Get the user info to set the creatorID Account userInfo = await HttpContext.GetUserInfoAsync <Account>(); // safety to make sure an account exists for that user before CREATE-ing stuff. _acctsService.GetOrCreateAccount(userInfo); newRecipe.CreatorId = userInfo.Id; Recipe recipe = _service.Create(newRecipe); return(Ok(recipe)); } catch (Exception e) { return(BadRequest(e.Message)); } }