Created
July 18, 2014 13:49
-
-
Save mahmut-gundogdu/0bcae6dc835a21c1d601 to your computer and use it in GitHub Desktop.
Nosql biggy ile asp.net de sabit verilerin ve uygulama ayarlarının saklanması. http://mahmutgundogdu.azurewebsites.net/?p=242
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Biggy; | |
using Biggy.JSON; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
namespace AYarlar | |
{ | |
public class Firma | |
{ | |
public string Adi { get; set; } | |
public string Telefon { get; set; } | |
public string Eposta { get; set; } | |
} | |
public class Ayarlar | |
{ | |
public Ayarlar() | |
{ | |
IBiggyStore<Firma> ayarlar = new JsonStore<Firma>(dbPath: HttpRuntime.AppDomainAppPath); | |
//Her durumda 1 tane ayar olması için single aldım. | |
this.firma= ayarlar.Load().SingleOrDefault(); | |
} | |
public Firma firma { get; set; } | |
public void Kaydet() | |
{ | |
IBiggyStore<Firma> ayarlar = new JsonStore<Firma>(dbPath: HttpRuntime.AppDomainAppPath); | |
var x = ayarlar.Load().SingleOrDefault(); | |
if (x != null) | |
{ | |
x = this.firma; | |
ayarlar.Update(x); | |
} | |
else | |
{ | |
ayarlar.Add(this.firma); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AYarlar.Default" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<% AYarlar.Ayarlar s = new AYarlar.Ayarlar(); | |
if (s.firma != null) | |
{%> | |
<h3><%=s.firma.Adi %> </h3> | |
<p> | |
Telefon: <%=s.firma.Telefon %> | |
<br /> | |
Eposta <%=s.firma.Eposta %> | |
</p> | |
<%} else { %> | |
<div> | |
SirketAdi:<asp:TextBox runat="server" ID="txtSirketAdi" /><br /> | |
Telefon::<asp:TextBox runat="server" ID="txtTel" /><br /> | |
Eposta:<asp:TextBox runat="server" ID="txtEposta" /><br /> | |
<asp:Button Text="Kaydet" ID="btnKaydet" OnClick="btnKaydet_Click" runat="server" /> | |
</div> | |
<% } %> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
namespace AYarlar | |
{ | |
public partial class Default : System.Web.UI.Page | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
} | |
protected void btnKaydet_Click(object sender, EventArgs e) | |
{ | |
Firma s = new Firma(); | |
Ayarlar data = new Ayarlar(); | |
s.Eposta = txtEposta.Text; | |
s.Telefon = txtTel.Text; | |
s.Adi = txtSirketAdi.Text; | |
data.firma = s; | |
data.Kaydet();//bu fonksiyon ile datamız kaydedildi. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment