views:

61

answers:

0

I'm using the jQuery UI datepicker to display the daily exchange rate. I have four textbox, the first for displaying today's date, and the others for displaying the dollar rate, buying rate and selling rate. The dollar rate is fixed and is set to 1. The buying rate and selling rate are updated daily and inserted into exchange rate table database. Click here for screenshot of my UI.

But what I need is to show exchange rate data on clicking the specific day on these textbox. (All data is stored in database).

Here's the code for my ExchangeRate controller:

public ActionResult ExchangeRates()
{
    ExchangeRate er = Ers.GetExchangeRateForToday(DateTime.Now);
    if (er != null)
    {
        ViewData["ExchangeRate"] = er;
    }
    else
    {
        //ExchangeRate erR = new ExchangeRate();
        //erR.CurrentDate = null;
        //erR.BuyingRate = null;
        //ViewData["ExchangeRate"] = er;
        ViewData["ExchangeRate"] = Ers.GetExchangeRateForToday(DateTime.Now);
    }
    //TempData["UpdateStatus"] = "Details updated";
    SetUserTypeForNavigationOptions();
    return View();
}

[AcceptVerbs(HttpVerbs.Post)]
//[ValidateInput(false)]
public ActionResult ExchangeRates(FormCollection fc)
{
    // long eXchangeRateId = Convert.ToInt64(fc["ErId"]);
    // ExchangeRate rate = Ers.GetSingleExchangeRate(eXchangeRateId);
    SetUserTypeForNavigationOptions();
    if (tUsvc.ValidateExchangeRate(fc["Duedate"], fc["BuyingRate"]))
    {
        ExchangeRate rate = new ExchangeRate();
        rate.CurrentDate = Convert.ToDateTime(fc["Duedate"]);
        rate.DollarRate = Convert.ToInt32(fc["Dollar"]);
        rate.BuyingRate = Convert.ToDecimal(fc["BuyingRate"]);
        rate.SellingRate = Convert.ToDecimal(fc["SellingRate"]);
        Ers.Add(rate);
    }
    else
    {
        ViewData["ExchangeRate"] = Ers.GetAll().Last();
        return View("ExchangeRates");
    }
    ExchangeRate erate  =  Ers.GetAll().Last();
    ViewData["ExchangeRate"] = Ers.GetSingleExchangeRate(erate.Id);
    return View();
}