Basically a button functionality the changes the data in a record in a database.
Pseudo:
If record in DB = 1, on button click, change to 2 Else if record in DB = 2, on button click, change to 1
Thank in advance for any tips/help
Amy you can edit your question and post the code there and apply proper formatting.
Since it is your 1st web app and it is tips/ help you are looking for :
These links will help you understand web-apps and MVC3 better - Come back here with any question you got after trying out these tutorials.
Sudo controller action.
public ActionResult DetailsChanged(DetailsRepository detailsRepository, Details detailsModel)
{
if(!ModelState.Valid)
{
ViewData["Error"] = "Error";
return View();
}
Details newDetails = detailsRepository.FirstOrDefault(x => x.ID == detailsModel.Id);
if(newDetails != null)
{
if(newDetails.Id == 1)
{
newDetails.Id = 2;
} else {
newDetails.Id = 2;
}
detailsRepository.SaveChanges();
return View();
}
}
Something like that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.