I have a problem with a function: when I click a button, a code block is running but when the user clicks the button or link more than once, this code block is running more than once without the run being completed.
So some times it writes data to the database twice. I'm using ASP.NET MVC and C#.
Here my example code:
[Route("Reservations")]
public ActionResult Index()
{
MTAPI mTAPI = new MTAPI();
mTAPI.VeriAl();
reservations.EditPassedTourTime();
reservation.Raccount = reservations.GetAllResAccountLMTD();
return View(reservation);
}
public void VeriAl()
{
int VoucherId = rservations.GetLastVoucher().fldId;
using (example _db= new example())
{
var newdata =_db.Voucher();
newdata.beforerecordId = VoucherId;
_db.Voucher.Add(newdata);
_db.SaveChanges();
}
}