예제 #1
0
    public bool Add(string title, string description, string userName, string token, string base64 = "", string fileName = "")
    {
        if (token != WebConfigurationManager.AppSettings["token"])
        {
            return(false);
        }
        const bool isActive = false;
        var        filePath = "";

        if (!string.IsNullOrEmpty(base64))
        {
            try
            {
                var path = Path.GetExtension(fileName);
                filePath = AdoFunc.GetUniqueKey(60) + path;
                var serverPath = Server.MapPath("images/" + filePath);
                using (var fs = new FileStream(serverPath, FileMode.Create))
                {
                    using (var bw = new BinaryWriter(fs))
                    {
                        byte[] data = Convert.FromBase64String(base64);
                        bw.Write(data);
                        bw.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        return(AdoFunc.Cmd(@"insert into News (Title, Description, UserName, IsActive, FilePath) values ('" + title.ClearSql() + "','" + description.ClearSql() + "','" + userName.ClearSql() + "','" + isActive + "','" + filePath.ClearSql() + "')") > 0);
    }
예제 #2
0
    public List <News> List()
    {
        var data   = AdoFunc.GetDataTable("select * from News where IsActive=1");
        var models = AdoFunc.Map <News>(data).ToList();

        return(models);
    }
예제 #3
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        var userName = txtUserName.Text;
        var passWord = txtPassword.Text;
        var userId   = Convert.ToInt32(AdoFunc.GetDataCell("select count(UserId) from Users where UserName='******' and Password="******"UserId"] = userId;
            Response.Redirect("/");
        }
        else
        {
            lblInfo.Text    = "Kullanıcı adı yada şifre yanlış";
            lblInfo.Visible = true;
        }
    }
예제 #4
0
    protected void rptNews_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Publish")
        {
            var data   = e.CommandArgument.ToString().ClearSql().Split(',');
            var id     = Convert.ToInt32(data[0]);
            var status = data[1] == "True" ? 0 : 1;
            var result = AdoFunc.Cmd("update News set IsActive=" + status + " where NewsId=" + id);
            if (result > 0)
            {
                lblInfo.Text = status == 0 ? "Haber başarılı bir şekilde yayından kaldırıldı" : "Haber başarılı bir şekilde yayınlandı.";;
                List();
            }
            else
            {
                lblInfo.Text = "Bir hata oluştu lütfen daha sonra tekrar deneyiniz.";
            }

            lblInfo.Visible = true;
        }
    }
예제 #5
0
 public void List()
 {
     rptNews.DataSource = AdoFunc.GetDataTable("select * from News");
     rptNews.DataBind();
 }