Write to the Database at the end of the auction

0

I'm developing an auction site in ASP.NET MVC4 and EF, at this time already runs bids and has a timer.

The problem now is: how do I record the data when the time expires? I've thought about doing a trigger in DB, but I think it will not work.

I think I have to have a script that detects that the time has expired and writes the data to the DB, but how do I do this?

I have the timer in JavaScript:

<script type="text/javascript"> 
    $('#countdown').countdown({ until: '@timeSpan', format: 'DHMS' }); 
</script> 
    
asked by anonymous 28.05.2014 / 02:36

1 answer

2

In the jQuery Countdown documentation, there is a parameter named expiryUrl . It can be used to make an Ajax request for some% of its%.

<script type="text/javascript"> 
    $('#countdown').countdown({ 
        until: '@timeSpan', 
        format: 'DHMS',
        expiryUrl: '˜/MeuController/ActionAposExpirarTempo/?parametro=valor' 
    }); 
</script>

Then just create Controller in Action :

public JsonResult ActionAposExpirarTempo(String parametro) {
    // Faça alguma coisa aqui relacionada com a sua lógica

    return Json(new { status = "Ok"}, JsonRequestBehavior.AllowGet);
}

It's just an example. It does not necessarily need to return a JSON.

    
28.05.2014 / 04:09