public ActionResult <Keep> Create([FromBody] Keep newKeep) { string id = HttpContext.User.Identity.Name; newKeep.UserId = id; return(_kr.CreateKeep(newKeep)); }
public ActionResult <Keep> Create([FromBody] Keep newKeep) { var UserId = HttpContext.User.FindFirstValue("Id"); newKeep.UserId = UserId; return(_kr.CreateKeep(newKeep)); }
public Keep Create([FromBody] Keep newKeep) { // var user = HttpContext.User; // newKeep.UserId = user.Identity.Name; if (ModelState.IsValid) { return(db.CreateKeep(newKeep)); } return(null); }
public ActionResult <Keep> Create([FromBody] Keep keep) { keep.userId = HttpContext.User.Identity.Name; Keep newKeep = _pr.CreateKeep(keep); if (newKeep == null) { return(BadRequest("Keep creation failed!")); } return(Ok(newKeep)); }
[HttpPost] //NOTE "Can Create Keep" public ActionResult <Keep> Post([FromBody] Keep keep) { try { keep.UserId = HttpContext.User.FindFirstValue("Id"); // THIS IS HOW YOU GET THE ID of the currently logged in user return(Ok(_repo.CreateKeep(keep))); } catch (Exception e) { return(BadRequest("Incorrect Data")); } }
public ActionResult <Keep> Post([FromBody] Keep keep) { keep.UserId = HttpContext.User.FindFirstValue("Id"); try { return(Ok(_kr.CreateKeep(keep))); } catch (System.Exception) { throw; } }
public ActionResult <Keep> Post([FromBody] Keep keep) { try { keep.UserId = HttpContext.User.FindFirstValue("Id"); return(Ok(_repo.CreateKeep(keep))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public Keep CreateKeep(Keep newKeep) { newKeep.Id = _repo.CreateKeep(newKeep); return(newKeep); }
public Keep CreateKeep(Keep newKeep) { return(_repo.CreateKeep(newKeep)); }