// GET: /BusMonitor/
        public ActionResult Dashboard()
        {
            BusMonitorAnalysis     objBusMonitor = new BusMonitorAnalysis();
            BusMonitorAnalysisList objList       = new BusMonitorAnalysisList();

            try
            {
                objBusMonitor.AgencyId = new Guid(Session["AgencyId"].ToString());
                objBusMonitor.UserId   = new Guid(Session["UserID"].ToString());
                objList = new BusMonitorData().GetBusMonitorData(objBusMonitor);
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
            }

            return(View(objList));
        }
Beispiel #2
0
        public BusMonitorAnalysisList GetBusMonitorData(BusMonitorAnalysis busmonitor)
        {
            List <BusMonitorAnalysis> busmonitorList    = new List <BusMonitorAnalysis>();
            BusMonitorAnalysisList    getbusmonitorList = new BusMonitorAnalysisList();
            BusMonitorAnalysis        busmonitorData    = null;
            BusMonitorAnalysisTotal   objTotal          = new BusMonitorAnalysisTotal();

            try
            {
                command.Parameters.Clear();
                command.Parameters.Add(new SqlParameter("@AgencyId", busmonitor.AgencyId));
                command.Parameters.Add(new SqlParameter("@UserId", busmonitor.UserId));
                command.Connection  = Connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "USP_GetBusMonitor";
                DataAdapter         = new SqlDataAdapter(command);
                _dataset            = new DataSet();
                DataAdapter.Fill(_dataset);
                if (_dataset.Tables[0] != null)
                {
                    if (_dataset.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in _dataset.Tables[0].Rows)
                        {
                            busmonitorData           = new BusMonitorAnalysis();
                            busmonitorData.RouteName = dr["RouteName"].ToString();
                            busmonitorData.CenterId  = Convert.ToInt64(dr["CenterId"]);
                            // busmonitorData.Riders = Convert.ToInt32(dr["RidersCount"]);
                            busmonitorData.PickUp    = Convert.ToInt32(dr["PickUpCount"]);
                            busmonitorData.Drop      = Convert.ToInt32(dr["DropCount"]);
                            busmonitorData.RouteType = Convert.ToInt32(dr["RouteType"]);
                            busmonitorList.Add(busmonitorData);
                        }
                    }

                    if (busmonitorList.Count() > 0)
                    {
                        //  objTotal.RidersTotal = busmonitorList.Sum(x => x.Riders);
                        objTotal.PickUpTotal  = busmonitorList.Sum(x => x.PickUp);
                        objTotal.DropOffTotal = busmonitorList.Sum(x => x.Drop);
                    }
                    else
                    {
                        //  objTotal.RidersTotal = 0;
                        objTotal.PickUpTotal  = 0;
                        objTotal.DropOffTotal = 0;
                    }

                    getbusmonitorList.ListBusMonitor = busmonitorList;
                    getbusmonitorList.AnalysisTotal  = objTotal;
                }
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
            }
            finally
            {
                DataAdapter.Dispose();
                command.Dispose();
            }
            return(getbusmonitorList);
        }