Routing
routes.MapRoute( "YonetimAnasayfadaGizle", "tr/yonetim/makale/anasayfadagizle/{id}", new { Controller = "Yonetim", action = "AnasayfadaGizle", id = (int?)null } ); routes.MapRoute( "YonetimAnasayfadaGoster", "tr/yonetim/makale/anasayfadagoster/{id}", new { Controller = "Yonetim", action = "AnasayfadaGoster", id = (int?)null } );
View
$(document).ready(function () { $("input.arac").on("click", function () { if ($(this).is(':checked')) { $.post("/tr/yonetim/makale/anasayfadagoster/" + $(this).val()); } else { $.post("/tr/yonetim/makale/anasayfadagizle/" + $(this).val()); } }); $("#sortable").sortable({ opacity: 0.6, cursor: 'move', update: function () { var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; $.post("/tr/Yonetim/MakaleSirala2", order); } }); $("#sortable").disableSelection(); });
Controller
public void AnasayfadaGoster(int id) { using (var dbc = new DiscusEntities()) { Makale makalem = dbc.Makales.FirstOrDefault(a => a.MakaleID == id); makalem.Anasayfa = true; dbc.SaveChanges(); } } public void AnasayfadaGizle(int id) { using (var dbc = new DiscusEntities()) { Makale makalem = dbc.Makales.FirstOrDefault(a => a.MakaleID == id); makalem.Anasayfa = false; dbc.SaveChanges(); } }
View
< input class="arac" name="manakale-@(MakaleKat.MakaleID)" value="@(MakaleKat.MakaleID)" type="checkbox" @if (MakaleKat.Anasayfa == true) { @MvcHtmlString.Create("checked=\"checked\"") } size="2" />