TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
albert albert
NA
524
0
Move up/down record with LINQ
Jul 4 2014 1:12 AM
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},
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]
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.
Reply
Answers (
2
)
What Happens if routing is not there in MVC ?
Add Employee SubMenu Is not displayed on browser