Beispiel #1
0
        public IActionResult DeleteConfirmed(string id)
        {
            var blog = blogsService.GetBlogById(id);

            blogsService.Delete(blog);
            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult DeleteBlog(string id, [FromHeader] string password)
        {
            if (password != "rockrockwhite")
            {
                return(BadRequest(new Response <string>(new PasswordError())
                {
                    resultBody = ""
                }));
            }

            var blog = _blogsService.Get(id);

            if (blog == null)
            {
                return(NotFound(new Response <string>(new BlogIdError())
                {
                    resultBody = ""
                }));
            }

            _blogsService.Delete(id);

            return(Ok(new Response <Blog>(new Ok())
            {
                resultBody = blog
            }));
        }
Beispiel #3
0
 public ActionResult <Blog> Delete(int id)
 {
     try
     {
         return(Ok(_bs.Delete(id)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Beispiel #4
0
 [HttpDelete("{id}")] //Delort
 public ActionResult <string> DeleteBlogs(string id)
 {
     try
     {
         return(Ok(_service.Delete(id)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Beispiel #5
0
        public async Task <ActionResult <Blog> > DeleteAsync(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_bservice.Delete(id, userInfo.Id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
 public ActionResult <Blog> Delete(int id)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         // NOTE DONT TRUST THE USER TO TELL YOU WHO THEY ARE!!!!
         return(Ok(_bs.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Beispiel #7
0
        public async Task <ActionResult <string> > Delete(int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                return(Ok(_serv.Delete(id, userInfo.Email)));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
Beispiel #8
0
        public async Task <ActionResult <Blog> > Delete(int id)
        {
            try
            {
                Account userInfo = await HttpContext.GetUserInfoAsync <Account>();

                _bService.Delete(id, userInfo.Id);
                return(Ok("Succesfully Deleted"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <ActionResult <Blog> > Delete(int id)
        {
            try
            {
                // TODO[epic=Auth] Get the user info to set the creatorID
                Account userInfo = await HttpContext.GetUserInfoAsync <Account>();

                // safety to make sure an account exists for that user before DELETE-ing stuff.
                _service.Delete(id, userInfo.Id);
                return(Ok("Successfulyl Deleted!"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }