Пример #1
0
        public void OnPost(string ImageUrl, string Description, bool SmallImage, string EmbedColor, string SiteName)
        {
            if (Program.Config.ApiOnly)
            {
                Response.Redirect("/ApiOnly");
                return;
            }
            if (Url == null)
            {
                Response.Redirect("/error");
                return;
            }

            var name = Redirects.Create(new RedirectInfo
            {
                Url         = Url,
                Title       = Title,
                ImageUrl    = ImageUrl,
                Description = Description,
                SmallImage  = SmallImage,
                EmbedColor  = EmbedColor ?? "2F3136",
                SiteName    = SiteName
            });

            Response.Redirect($"/Created?name={name}");
        }
Пример #2
0
        public async Task <IActionResult> CreateRedirect()
        {
            string json;

            using (StreamReader reader = new StreamReader(Request.Body))
            {
                json = await reader.ReadToEndAsync();
            }
            var redirectInfo = JsonConvert.DeserializeObject <RedirectInfo>(json);

            // todo: add checks for too long SiteName, Description etc
            if (redirectInfo.Url == null | redirectInfo.Url == "")
            {
                return(BadRequest("Url must be specified"));
            }
            return(Content(Redirects.Create(redirectInfo)));
        }