コード例 #1
0
ファイル: KeepsController.cs プロジェクト: BauerSamuel/Keeper
        public ActionResult <Keep> Create([FromBody] Keep newKeep)
        {
            string id = HttpContext.User.Identity.Name;

            newKeep.UserId = id;
            return(_kr.CreateKeep(newKeep));
        }
コード例 #2
0
        public ActionResult <Keep> Create([FromBody] Keep newKeep)
        {
            var UserId = HttpContext.User.FindFirstValue("Id");

            newKeep.UserId = UserId;
            return(_kr.CreateKeep(newKeep));
        }
コード例 #3
0
 public Keep Create([FromBody] Keep newKeep)
 {
     // var user = HttpContext.User;
     // newKeep.UserId = user.Identity.Name;
     if (ModelState.IsValid)
     {
         return(db.CreateKeep(newKeep));
     }
     return(null);
 }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: KeepsController.cs プロジェクト: ryanochoa8/Keepr
 [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"));
     }
 }
コード例 #6
0
 public ActionResult <Keep> Post([FromBody] Keep keep)
 {
     keep.UserId = HttpContext.User.FindFirstValue("Id");
     try
     {
         return(Ok(_kr.CreateKeep(keep)));
     }
     catch (System.Exception)
     {
         throw;
     }
 }
コード例 #7
0
 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));
     }
 }
コード例 #8
0
 public Keep CreateKeep(Keep newKeep)
 {
     newKeep.Id = _repo.CreateKeep(newKeep);
     return(newKeep);
 }
コード例 #9
0
 public Keep CreateKeep(Keep newKeep)
 {
     return(_repo.CreateKeep(newKeep));
 }