Hi everybody,
I have 2 buttons: UP and Down.
And if you press up , then the record has to goes up and for down - the record has to go down.
This is the ajax call:
[code]
$.ajax({
type: 'POST',
url:Medicijnverstrekking.baseUrl + '/Medicijn/MoveUp/',
dataType: 'json',
data:{Id: dataItem.Id},
JavaScript
success: function (result) {
//$("#medicijnenGridVolgorde").data("kendoGrid").dataSource.data(result);
//if (newIndex != index) {
//grid.dataSource.remove(dataItem);
//grid.dataSource.insert(newIndex, dataItem);
//$("#medicijnenGridVolgorde").data("kendoGrid").dataSource.fetch();
// grid.dataSource.read();
grid.dataSource.refresh();
//}
}
})
return false;
}[code]
and this is the method in the controller:
[code]
Java
public ActionResult MoveUP(int id /*MedicijnViewModel model, HttpPostedFileBase bijsluiter*/)
{
var medicijn = medicijnService.GetById(id);
Item item = medicijnService.GetById(id). medicijn.Id. .Items.Single(i => i.Id == id);
if (medicijn.Id > 0)
{
medicijn predecessor = Context.Items.Single(i => i.Index == medicijn.Id - 1);
item.Index -= 1;
predecessor.Index += 1;
//predecessor;
medicijnService.Save(medicijn);
//Context.SaveChanges();
}
return View();
}[/code]
Thank you for your help.
albert albertRank #4,708 · 327 pointsPosted Jul 3, 2014, 9:59 PM EDT
public ActionResult MoveUP(int id /*MedicijnViewModel model, HttpPostedFileBase bijsluiter*/) { var medicijn = medicijnService.GetById(id); var medicijnTemp = medicijnService.GetById(id); //Item item = medicijnService.GetById(id). medicijn.Id.Items.Single(i => i.Id == id); medicijn = medicijnRepository.Query.Single(i => i.Id == id); if (medicijn.Id > 0) { //medicijn predecessor = Context.Items.Single(i => i.Index == medicijn.Id - 1); medicijnTemp = medicijnRepository.Query.Single(m => m.Id == medicijn.Id); medicijn.Id -= 1; medicijnService.GetById(id += 1); medicijnService.Save(medicijn); } return View(); }albert albertRank #4,708 · 327 pointsPosted Jul 3, 2014, 10:59 PM EDT
[code]
public ActionResult MoveUP(int id /*MedicijnViewModel model, HttpPostedFileBase bijsluiter*/) { var medicijn = medicijnService.GetById(id); var medicijnTemp = medicijnService.GetById(id); //Item item = medicijnService.GetById(id). medicijn.Id.Items.Single(i => i.Id == id); medicijn = medicijnRepository.Query.Single(i => i.Id == id); if (medicijn.Id > 0) { //medicijn predecessor = Context.Items.Single(i => i.Index == medicijn.Id - 1); medicijnTemp = medicijnRepository.Query.Single(m => m.Id == medicijn.Id); medicijn.Id -= 1; medicijnTemp.Id += 1; //medicijnService.GetById(id += 1); medicijnService.Save(medicijn); } return View(); }But if I look in this:
Then I see they have the same value.