コード例 #1
0
        public ActionResult <string> Delete(int id)
        {
            bool successful = _kr.Delete(id);

            if (!successful)
            {
                return(BadRequest());
            }
            return(Ok());
        }
コード例 #2
0
        internal Keep Delete(int id, string userId)
        {
            Keep original = GetById(id);

            if (userId != original.CreatorId)
            {
                throw new Exception("You can only delete your own data");
            }
            _repo.Delete(id);
            return(original);
        }
コード例 #3
0
        public ActionResult <string> Delete(int id)
        {
            string userId     = HttpContext.User.Identity.Name;
            bool   successful = _kr.Delete(id, userId);

            if (!successful)
            {
                return(BadRequest("Cannot Delete"));
            }
            return(Ok("successfully deleted"));
        }
コード例 #4
0
        public string Delete(int id)
        {
            string Deleted     = "Keep Deleted";
            bool   deletedKeep = _kr.Delete(id);

            if (deletedKeep)
            {
                return(Deleted);
            }
            ;
            throw new Exception("Not a valid Keep");
        }
コード例 #5
0
 public ActionResult <String> Delete(int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirstValue("Id");
         return(Ok(_repo.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
コード例 #6
0
ファイル: KeepService.cs プロジェクト: cunningdan/Keepr
        public string Delete(int id, string userId)
        {
            Keep original = _repo.GetOne(id);

            if (original == null)
            {
                throw new System.Exception("Bad Id");
            }
            if (original.CreatorId != userId)
            {
                throw new System.Exception("Not yours. Access Denied");
            }
            if (_repo.Delete(id))
            {
                return("Deleted successfully");
            }
            return("Not Deleted");
        }
コード例 #7
0
        internal string Delete(int id, string userId)
        {
            Keep data = _repo.FindById(id);

            if (data == null)
            {
                throw new Exception("Bad Id");
            }
            if (data.CreatorId != userId)
            {
                throw new Exception("Not user, Access Denied");
            }
            if (_repo.Delete(id))
            {
                return("deleted succesfully");
            }
            return("did not remove succesfully");
        }
コード例 #8
0
 public string Delete(int id)
 {
     return(_repo.Delete(id));
 }