コード例 #1
0
ファイル: KeepsController.cs プロジェクト: BradleyG248/Keepr
        public ActionResult <Keep> Put([FromBody] Keep editedKeep, int Id)
        {
            var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            editedKeep.UserId = userId;
            return(Ok(_ks.Edit(editedKeep)));
        }
コード例 #2
0
ファイル: KeepsController.cs プロジェクト: austinhugus/Keepr
 public ActionResult <Keep> Edit(int id, [FromBody] Keep editKeep)
 {
     try {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         editKeep.Id = id;
         return(Ok(_ks.Edit(editKeep, userId)));
     } catch (Exception e) {
         return(BadRequest(e.Message));
     }
 }
コード例 #3
0
 public ActionResult <Keep> Edit([FromBody] Keep newKeep, int id)
 {
     try
     {
         newKeep.Id = id;
         string reqUserId = HttpContext.User.FindFirstValue("Id");
         User   user      = _as.GetUserById(reqUserId);
         return(Ok(_ks.Edit(newKeep, user.Id)));
     }
     catch (Exception e) { return(BadRequest(e.Message)); }
 }
コード例 #4
0
ファイル: KeepsController.cs プロジェクト: G0SSZILLA/Keepr
 public ActionResult <Keep> Edit(int id, [FromBody] Keep keepToUpdate)
 {
     keepToUpdate.Id = id;
     try
     {
         return(Ok(_ks.Edit(keepToUpdate)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #5
0
 public ActionResult <Keep> Edit([FromBody] Keep editKeep, int id)
 {
     try
     {
         //   id = editKeep.Id;
         return(Ok(_ks.Edit(editKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #6
0
 public ActionResult <Keep> Edit([FromBody] Keep update, int id)
 {
     try
     {
         update.Id = id;
         return(Ok(_ks.Edit(update)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #7
0
ファイル: KeepsController.cs プロジェクト: mralext20/keepr
 public ActionResult <Keep> Edit([FromBody] Keep update, int id)
 {
     try
     {
         update.Id = id;
         return(_ks.Edit(update, HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #8
0
ファイル: KeepsController.cs プロジェクト: Itzmack117/Keepr
 public ActionResult <Keep> Edit(int id, [FromBody] Keep keepUpdate)
 {
     try
     {
         keepUpdate.Id = id;
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_ks.Edit(keepUpdate, userId)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #9
0
 public ActionResult <Keep> EditKeep([FromBody] Keep KeepData)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         KeepData.UserId = userId;
         return(Ok(_ks.Edit(KeepData)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #10
0
 public ActionResult <Keep> Put([FromBody] Keep editedKeep, int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         editedKeep.UserId = userId;
         return(Ok(_ks.Edit(editedKeep, id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #11
0
 public ActionResult <Keep> Edit([FromBody] Keep newKeep, int id)
 {
     try
     {
         string userId = findUserInfo();
         newKeep.Id = id;
         return(Ok(_ks.Edit(newKeep, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #12
0
 public ActionResult <Keep> Edit(int id, [FromBody] Keep updatedKeep)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         updatedKeep.UserId = userId;
         return(Ok(_ks.Edit(id, updatedKeep)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #13
0
 public ActionResult <Keep> Edit([FromBody] Keep newKeep, int id)
 {
     try
     {
         newKeep.Id     = id;
         newKeep.UserId = HttpContext.User.FindFirstValue("Id");
         return(Ok(_ks.Edit(newKeep)));
     }
     catch (Exception e)
     {
         return(Unauthorized(e.Message));
     }
 }
コード例 #14
0
ファイル: KeepsController.cs プロジェクト: JacobCrombie/keepr
        public async Task <ActionResult <Keep> > Edit([FromBody] Keep updatedKeep, int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_keepsServ.Edit(updatedKeep, userInfo.Id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #15
0
 public ActionResult<Keep> Edit(int keepId, [FromBody] Keep updatedKeep)
 {
   try
   {
     string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
     updatedKeep.UserId = userId;
     updatedKeep.Id = keepId;
     return Ok(_ks.Edit(updatedKeep));
   }
   catch (Exception e)
   {
     return BadRequest(e.Message);
   }
 }
コード例 #16
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromQuery] Keep updated)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                updated.Id = id;
                return(Ok(_ks.Edit(updated, userInfo)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #17
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep editedKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editedKeep.Id = id;
                return(Ok(_keepsService.Edit(editedKeep, userInfo)));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
コード例 #18
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep editKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editKeep.Id = id;
                return(Ok(_ks.Edit(editKeep, userInfo.Id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #19
0
        public ActionResult <Keep> Edit([FromBody] Keep keep)
        {
            try
            {
                string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

                keep.UserId = userId;
                return(Ok(_ks.Edit(keep)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #20
0
        async public Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep keepBody)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                keepBody.Id = id;
                Keep updatedKeep = _service.Edit(keepBody, userInfo.Id);
                return(Ok(updatedKeep));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
コード例 #21
0
 public ActionResult <Keep> Edit(int id, [FromBody] Keep updatedKeep)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         // NOTE DONT TRUST THE USER TO TELL YOU WHO THEY ARE!!!!
         updatedKeep.UserId = userId;
         updatedKeep.Id     = id;
         return(Ok(_ks.Edit(updatedKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #22
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep editData)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                //helpful to check in service if creator is whoever is logged in
                editData.Id = id;
                return(Ok(_ks.Edit(editData, userInfo.Id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #23
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep editData)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editData.Id        = id;
                editData.Creator   = userInfo;
                editData.CreatorId = userInfo.Id;
                return(Ok(_kService.Edit(editData, userInfo.Id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #24
0
ファイル: KeepsController.cs プロジェクト: amgorder/keepr
        public async Task <ActionResult <Keep> > Edit([FromBody] Keep updated, int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                updated.CreatorId = userInfo.Id;
                updated.Creator   = userInfo;
                updated.Id        = id;
                return(Ok(_service.Edit(updated)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #25
0
        public async Task <ActionResult <Keep> > Edit([FromBody] Keep payload, int id)
        {
            try
            {
                Profile user = await HttpContext.GetUserInfoAsync <Profile>();

                payload.CreatorId = user.Id;
                payload.Creator   = user;
                payload.Id        = id;
                return(Ok(_serv.Edit(payload)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #26
0
        public async Task <ActionResult <Keep> > EditAsync(int id, [FromBody] Keep keep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                keep.Id        = id;
                keep.CreatorId = userInfo.Id;
                keep.Creator   = userInfo;
                return(Ok(_kService.Edit(keep, userInfo.Id)));
            }
            catch (System.Exception err)
            {
                return(BadRequest(err.Message));
            }
        }
コード例 #27
0
 public ActionResult <Keep> Edit(int id, [FromBody] Keep updatedKeep)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Must be logged in to edit");
         }
         return(Ok(_ks.Edit(id, updatedKeep)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #28
0
        public async Task <ActionResult <Keep> > Edit(int id, [FromBody] Keep editKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editKeep.CreatorId = userInfo.Id;
                editKeep.Creator   = userInfo;
                editKeep.Id        = id;

                return(Ok(_service.Edit(editKeep, userInfo.Id)));
            }
            catch (System.Exception)
            {
                throw;
            }
        }
コード例 #29
0
 public ActionResult <Keep> Edit([FromBody] Keep newKeep, int id)
 {
     try
     {
         Claim userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (newKeep.UserId != userId.Value)
         {
             throw new Exception("You can only edit your keeps");
         }
         newKeep.Id = id;
         return(Ok(_ks.Edit(newKeep, userId.Value)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #30
0
ファイル: KeepsController.cs プロジェクト: natesherfick/keepr
 public ActionResult <Keep> Edit([FromBody] Keep keepToUpdate)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Please log in.");
         }
         string userId = user.Value;
         return(Ok(_ks.Edit(keepToUpdate, userId)));
     }
     catch (System.Exception)
     {
         throw;
     }
 }