Example #1
0
        /// <summary>
        /// 添加友情连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            int    place = Convert.ToInt32(ddlPlace.SelectedValue);
            string name  = this.txtLinkName.Text.Trim();
            string title = this.txtLinkTitle.Text.Trim();
            string url   = this.txtLinkUrl.Text.Trim();

            if (name.Length == 0 || url.Length == 0)
            {
                lblError.Text = "各项不能为空";
                return;
            }
            Links item = new Links();

            item.linkname  = name;
            item.linktitle = title;
            item.linkurl   = url;
            item.addtime   = DateTime.Now;
            item.istj      = place;
            if (lblId.Text != "")
            {
                item.id = Convert.ToInt32(lblId.Text.Trim());
                int num = LinksService.Update(item);
            }
            else
            {
                int num = LinksService.Add(item);
            }
            pnlAdd.Visible  = false;
            pnlList.Visible = true;
            sp.InitBindData(repInfo, pager1, "Links", "id", sear());
        }
Example #2
0
        public async Task <IActionResult> AddUrl(string url, [ModelBinder(Name = "g-recaptcha-response")] string captcha)
        {
            if (!string.IsNullOrWhiteSpace(url) && !string.IsNullOrWhiteSpace(captcha))
            {
                if (await _captcha.Validate(captcha))
                {
                    await _links.Add(url);

                    TempData["notification"] = "Thanks for submitting a new link for The Week in .NET.";
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Example #3
0
        public async Task <IActionResult> Add(AddLinkUpdateModel addLinkUpdateModel)
        {
            var submitter = await _apiKeyService.Find(addLinkUpdateModel.ApiKey);

            if (submitter == null)
            {
                TempData["error"] = "No valid API key was submitted with this link.";
            }
            await _linksService.Add(
                addLinkUpdateModel.Url,
                addLinkUpdateModel.Title,
                addLinkUpdateModel.Author,
                addLinkUpdateModel.Category,
                submitter.OwnerName);

            TempData["notification"] = "Thanks for submitting a new link for The Week in .NET.";
            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
        private void BtnSalva_Click(object sender, RoutedEventArgs e)
        {
            _link.Titolo      = txtTitolo.Text;
            _link.Descrizione = txtDescrizione.Text;
            _link.URL         = txtUrl.Text;
            _link.IdCategoria = ((Categoria)cmbCategoria.SelectedItem).IdCategoria;

            if (_link.IdLink > 0)
            {
                linkService.Edit(_link);
                //MessageBox.Show("Link modificato", "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                linkService.Add(_link);
                //MessageBox.Show("Link aggiunto", "", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            this.DialogResult = true;
        }