Ejemplo n.º 1
0
        public ActionResult Index(int?id)
        {
            if (id != null)
            {
                var std = trepositery.Gettrainstationlist(Convert.ToInt32(id));
                if (std.Count > 0)
                {
                    ViewBag.hdnTrainid = id;
                    int    delay = Convert.ToInt32(std.Where(a => a.Delay != null).FirstOrDefault().Delay);
                    string s     = btrain.UpcomingStations(Convert.ToInt32(id));
                    ViewBag.stationame = s;
                    ViewBag.Delay      = delay;
                    TimeSpan arrival = std.Where(a => a.StationName == s).FirstOrDefault().ArrivalTime;
                    if (arrival < DateTime.Now.TimeOfDay)
                    {
                        ViewBag.Arrivaltime = "Reached Endpoint";
                    }
                    else
                    {
                        ViewBag.Arrivaltime = arrival;
                    }
                    if (delay != 0)
                    {
                        TimeSpan ts = TimeSpan.FromMinutes(delay);
                        ts = ts + arrival;
                        if (ts < DateTime.Now.TimeOfDay)
                        {
                            ViewBag.Arrivaltime = "Reached Endpoint";
                        }
                        else
                        {
                            ViewBag.Arrivaltime = ts;
                        }
                        //ViewBag.Arrivaltime = ts;
                    }
                }
                return(View(std));
            }
            //if (Request.QueryString["code"] != null)
            //{
            //    IUsersManagment ium = new UsersManagement();
            //    string trainid = Request.Form["hdntrianid"].ToString();
            //    string redirection_url = "http://localhost:50602/Home/Index";
            //    bool result = ium.GetToken(Request.QueryString["code"].ToString(), redirection_url);
            //    if (result)
            //        ViewBag.Sucess = "Notification Sent Sucessfully";
            //    else
            //        ViewBag.OauthErr = "Failed to login Please try again.";


            //}
            ViewBag.Title = "Home Page";

            return(View());
        }