예제 #1
0
        public ActionResult CreateSnippet(CreateSnippetRequest snippetRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Snippet snippet = _snippetService.Create(snippetRequest);

            //if it has no creatorEmail then create a job to destroy if after 10 minutes
            if (string.IsNullOrEmpty(snippetRequest.CreatorEmail))
            {
                BackgroundJob.Schedule(
                    () => _snippetService.DeleteSnippet(snippet.Hash),
                    TimeSpan.FromMinutes(10));
            }

            return(new JsonResult(new { status = HttpStatusCode.Created, hash = snippet.Hash }));
        }
예제 #2
0
        public ActionResult DeleteSnippet(int id)
        {
            bool res = _snippetService.DeleteSnippet(id);

            return(RedirectToAction("Snippets"));
        }