예제 #1
0
 public ActionResult <string> Delete(int id)
 {
     try {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_ks.Delete(id, userId)));
     } catch (Exception e) {
         return(BadRequest(e.Message));
     }
 }
예제 #2
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         string reqUserId = HttpContext.User.FindFirstValue("Id");
         User   user      = _as.GetUserById(reqUserId);
         return(Ok(_ks.Delete(id, user.Id)));
     }
     catch (Exception e) { return(BadRequest(e.Message)); }
 }
예제 #3
0
 public ActionResult <String> Delete(int id)
 {
     try
     {
         return(Ok(_ks.Delete(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
예제 #4
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         return(Ok(_ks.Delete(id)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
예제 #5
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         string userId = findUserInfo();
         return(Ok(_ks.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public void CanDelete()
        {
            Keep keepToDelete = new Keep {
                Name = "keepToDelete", Id = 1
            };

            moqKeepsRepository.Setup(repo => repo.GetById(1)).Returns(keepToDelete);
            moqKeepsRepository.Setup(repo => repo.Delete(1));

            var result = keepsService.Delete(1);

            Assert.AreEqual("Successfully Deleted", result);
        }
예제 #7
0
 public ActionResult<Keep> Delete(int keepId)
 {
   try
   {
     // NOTE DONT TRUST THE USER TO TELL YOU WHO THEY ARE!!!!
     string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
     return Ok(_ks.Delete(keepId, userId));
   }
   catch (Exception e)
   {
     return BadRequest(e.Message);
   }
 }
예제 #8
0
        public ActionResult Delete([FromRoute] int id)
        {
            var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            try
            {
                return(Ok(_ks.Delete(id, userId)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #9
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userinfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_ks.Delete(id, userinfo.Id)));
            }
            catch (System.Exception)
            {
                return(BadRequest("Cannot Delete"));
            }
        }
예제 #10
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_ks.Delete(id, userInfo.Id)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #11
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_keepsService.Delete(id, userInfo)));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
예제 #12
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         var userClaim = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         var userId    = userClaim.Value;
         return(Ok(_ks.Delete(id, userId)));
     }
     catch (System.Exception error)
     {
         return(BadRequest(error.Message));
     }
 }
예제 #13
0
        public async Task <ActionResult <Boolean> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                Boolean deleted = _keepsService.Delete(id, userInfo);
                return(Ok(deleted));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #14
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                Profile foundProfile = _ps.GetOrCreateProfile(userInfo);
                _ps.deleteKeepCount(foundProfile);
                return(Ok(_ks.Delete(id, foundProfile.Id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #15
0
 public ActionResult <Keep> Delete(int id)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Please Make Sure You Are Logged In.");
         }
         return(Ok(_ks.Delete(user.Value, id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     };
 }
예제 #16
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (userId == null)
         {
             throw new Exception("Please Login to Continue!");
         }
         return(Ok(_ks.Delete(userId.Value, id)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
예제 #17
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("You must be logged in to delete any keeps.");
         }
         return(Ok(_ks.Delete(user.Value, id)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
예제 #18
0
        public ActionResult <Keep> Delete(int id)
        {
            string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (userId == null)
            {
                throw new Exception("no id provided...");
            }
            try
            {
                return(Ok(_ks.Delete(id, userId)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #19
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         Claim user = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);
         if (user == null)
         {
             throw new Exception("Please log in.");
         }
         string userId = user.Value;
         return(Ok(_ks.Delete(id, userId)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
예제 #20
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_ks.Delete(id, userInfo.Id)));
            }
            catch (NotAuthorized e)
            {
                return(StatusCode(StatusCodes.Status403Forbidden, e.Message));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #21
0
        public ActionResult <bool> Delete(int id)
        {
            var userId = HttpContext.User.FindFirstValue("Id");

            return(Ok(_service.Delete(id, userId)));
        }