public ActionResult <Recipe> Create([FromBody] Recipe newRec)
 {
     try
     {
         return(Ok(_rs.Create(newRec)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 2
0
 public ActionResult <Recipe> Create([FromBody] Recipe newRecipe)
 {
     try
     {
         return(Ok(_service.Create(newRecipe)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
        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));
            }
        }