Esempio n. 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 }));
        }