@{
Layout = “~/Views/Shared/_Layout.cshtml”;
}
<h2>MVC 4 WinApi Uygulaması </h2>
<a href=”http://www.google.co.uk/” onclick=”return (confirm(‘Follow this link?’))”>Google</a>
<link href=”~/Content/css/ui-lightness/jquery-ui-1.9.2.custom.min.css” rel=”stylesheet” />
<script src=”~/Scripts/jquery-1.8.3.js”></script>
<script src=”~/Scripts/jquery-ui-1.9.2.custom.min.js”></script>
<h2>Kisiler</h2></br></br>
<form id=”fooo” >
<label for=”fooo”>Yeni İsim</label> <input id=”Ad” name=”Isim” type=”text” value=”” /></br/>
<label for=”fooo”>Yeni Yaş</label> <input id=”Yas” name=”Yas” type=”text” /></br/>
<label for=”fooo”>Yeni Şehir</label> <input id=”Sehir” name=”Sehir” type=”text” /></br>
</form>
<form id=”foo” >
<label for=”foo” >ID</label> <input id=”No” name=”Id” type=”text” value=”” /></br/>
<label for=”foo”>Yeni İsim</label> <input id=”Ad” name=”Isim” type=”text” value=”” /></br/>
<label for=”foo”>Yeni Yaş</label> <input id=”Yas” name=”Yas” type=”text” /></br/>
<label for=”foo”>Yeni Şehir</label> <input id=”Sehir” name=”Sehir” type=”text” /></br>
***********************************************************************************
<label for=”foo”><b>Kaydet</b></label> <input id=”Kyt” type=”button” value=”Kaydet” />
<label for=”foo”><b>Kayıt Bul</b></label> <input id=”Nosu” type=”text” /></br/> <input type=”button” id=”Bul” value=”Kayıt Bul” />
<label for=”foo”><b>Güncelle</b></label> <input type=”button” id=”Gun” value=”Güncelle” />
<label for=”foo”><b>Sil</b></label> <input type=”submit” id=”Sil” value=”Sil” />
</form>
<script type=”text/javascript”>
$(document).ready(function () {
$(‘#fooo’).hide()
$.ajax({
type: “GET”,
url: “/api/kisi”,
data: “{}”,
beforeSend: function () {
$(“img”).fadeIn(600)
}
,
contentType: “application/json; charset=utf-8”,
error: function () { $(“#infoBox”).html(”
Hata Var.
“); },
success: function (msg) {
var strMovies = “”;
$.each(msg, function (i, msg) {
strMovies += ”
” +
“<div>” + msg.Isim + “</div>” +
“<div>” + msg.Yas + “</div>” +
“<div>” + msg.Sehir + “</div>” +
“****************”;
});
$(“#result”).html(strMovies);
$(“img”).fadeOut(600);
$(‘#foo’).find(‘#No’).hide();
}
});
});
$(“#Kyt”).click(function () {
$(‘#fooo’).find(‘#Ad’).val($(‘#foo’).find(‘#Ad’).val());
$(‘#fooo’).find(‘#Yas’).val($(‘#foo’).find(‘#Yas’).val());
$(‘#fooo’).find(‘#Sehir’).val($(‘#foo’).find(‘#Sehir’).val());
$.ajax({
url: “/api/kisi”,
dataType: ‘json’,
data: $(‘#fooo’).serialize(),
type: “POST”,
success: function (response) {
myFunction();
},
error: function (err) {
}
});
});
$(‘#Bul’).click(function () {
var id = $(‘#Nosu’).val();
$.ajax({
url:”/api/kisi/”+id,
data: { id: id },
type: “GET”,
contentType: “application/json; charset=utf-8”,
success: function (evt) {
$(‘#foo’).find(‘#Ad’).val(evt.Isim);
$(‘#foo’).find(‘#Yas’).val(evt.Yas);
$(‘#foo’).find(‘#Sehir’).val(evt.Sehir);
$(‘#foo’).find(‘#No’).val(evt.Id);
}
});
});
$(‘#Gun’).click(function () {
var Id = $(‘#foo’).find(‘#No’).val();
$.ajax({
url: “/api/kisi/”+Id,
dataType: ‘json’,
data: $(‘#foo’).serialize(),
type: “PUT”,
//contentType: “application/json;charset=utf-8”,
success: function (response) {
alert(“Güncelleme Yapıldı “);
myFunction();
},
error: function (err) {
}
});
});
$(‘#Sil’).click(function () {
var Id = $(‘#foo’).find(‘#No’).val();
$.ajax({
url: “/api/kisi/” + Id,
dataType: ‘json’,
data: $(‘#foo’).serialize(),
type: “DELETE”,
success: function (response) {
alert(“Kayıt Silindi”);
//location.reload(true);
myFunction();
},
error: function (err) {
}
});
});
function myFunction() {
$.ajax({
type: “GET”,
url: “/api/kisi”,
data: “{}”,
beforeSend: function () {
$(“img”).fadeIn(600)
}
,
contentType: “application/json; charset=utf-8”,
error: function () { $(“#infoBox”).html(”
Hata Var.
“); },
success: function (msg) {
var strMovies = “”;
$.each(msg, function (i, msg) {
strMovies += ”
” +
“<div>” + msg.Isim + “</div>” +
“<div>” + msg.Yas + “</div>” +
“<div>” + msg.Sehir + “</div>” +
“****************”;
});
$(“#result”).html(strMovies);
$(“img”).fadeOut(600);
$(‘#foo’).find(‘#No’).hide();
}
});
}
</script>
<img src=”~/Images/ajax-loader.gif” />
<div id=”result”>.</div>
<div id=”liste”>.</div>
<div id=”infoBox”>…</div>