/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public StatusViewModel GetTipStatusViewModel(string tipYear) { StatusViewModel model = new StatusViewModel(); SqlCommand cmd = new SqlCommand("[TIP].[GetStatus]"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@TIPYEAR", SqlDbType.NVarChar)); cmd.Parameters[0].Value = tipYear; model.TipSummary.TipYear = tipYear; var sm = new TipStatusModel(); using (IDataReader rdr = this.ExecuteReader(cmd)) { if(rdr.Read()) { sm.ProgramId = (int)rdr["ProgramId"]; sm.TimePeriodId = Convert.ToInt32(rdr["TimePeriodId"]); sm.TipYear = rdr["TimePeriod"].ToString(); sm.Adoption = rdr["AdoptionDate"] != DBNull.Value ? (DateTime?)rdr["AdoptionDate"] : null; sm.EPAApproval = rdr["USEPAApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USEPAApprovalDate"] : null; sm.GovernorApproval = rdr["GovernorApprovalDate"] != DBNull.Value ? (DateTime?)rdr["GovernorApprovalDate"] : null; sm.LastAmended = rdr["LastAmendmentDate"] != DBNull.Value ? (DateTime?)rdr["LastAmendmentDate"] : null; sm.PublicHearing = rdr["PublicHearingDate"] != DBNull.Value ? (DateTime?)rdr["PublicHearingDate"] : null; sm.USDOTApproval = rdr["USDOTApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USDOTApprovalDate"] : null; sm.Notes = rdr["Notes"].ToString(); sm.IsCurrent = (bool)rdr["Current"]; sm.IsPending = (bool)rdr["Pending"]; sm.IsPrevious = (bool)rdr["Previous"]; sm.ShowDelayDate = rdr["ShowDelayDate"] != DBNull.Value ? (DateTime)rdr["ShowDelayDate"] : default(DateTime); } } model.TipStatus = sm; return model; }
public ActionResult Status(string year) { // get the view model from the repo var tipYearId = TripsRepository.GetTipYearId(year); var viewModel = new StatusViewModel(); viewModel.TipSummary.TipYear = year; viewModel.TipStatus = TripsRepository.GetTipStatus(tipYearId); return View(viewModel); }