I am passing a DateTime value back from a view using [HttpPost]
to the Controller. I have another method in the controller which i want to the result of the HttpPost method too. Or of i can pass the HttpPost back to the view.
What i want is to display the value of the LINQ in the form from the HttpPost method.
The original method that i use which populates the view is as follows.
public ActionResult Index()
{
ViewBag.Message = "Real Time Production";
DateTime ShiftStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
DateTime StartShift = ShiftStart.AddHours(7);
DateTime EndDate = StartShift.AddDays(1);
try
{
var PumaProduct =
new
{
PumaCastGood =
(from item in db.tbl_dppITHr
where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
select item).Sum(x => x.PumaCastGross) ?? 0,
PumaScrap =
(from item in db.tbl_dppITHr
where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
select item).Sum(x => x.PumaScrap) ?? 0,
PumaMachined =
(
from item in db.tbl_dppITHr
where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
select item).Sum(x => x.PumaMachined) ?? 0,
PumaHeatTreat =
(
from item in db.tbl_dppITHr
where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
select item).Sum(x => x.ATIPuma) ?? 0,
PumaShipped =
(
from item in db.tbl_dppITHr
where item.ProductionHour >= StartShift && item.ProductionHour <= EndDate
select item).Sum(x => x.PumaShipped) ?? 0,
};
ViewData["PumaCastGood"] = PumaProduct.PumaCastGood;
ViewData["PumaCastScrap"] = PumaProduct.PumaScrap;
ViewData["PumaMachined"] = PumaProduct.PumaMachined;
ViewData["PumaShipped"] = PumaProduct.PumaShipped;
ViewData["PumaHeatTreat"] = PumaProduct.PumaHeatTreat;
The following is the HttpPost method that i would like to pass to the ActionResult Index or pass to the view along with the item in Index method.
[HttpPost]
public ActionResult GetSigmaDateInfo(string dp)
{
DateTime SelectedDate = Convert.ToDateTime(dp);
DateTime SelectedDateDayShiftStart = SelectedDate.AddHours(7);
DateTime SelectedDateDayShiftEnd = SelectedDate.AddHours(19);
var SigmaData =
from n in db.tbl_dppITHr
where n.ProductionHour >= SelectedDateDayShiftStart
where n.ProductionHour <= SelectedDateDayShiftEnd
select n;
return View();
}
I have tried the normal C# method of passing method values between methods.