public IActionResult Index()
        {
            ViewData["Name"] = HttpContext.Session.GetString("UName");
            ViewData["Type"] = HttpContext.Session.GetString("Type");
            UserContext           userContext = HttpContext.RequestServices.GetService(typeof(UserContext)) as UserContext;
            HackathonContext      context     = HttpContext.RequestServices.GetService(typeof(HackathonContext)) as HackathonContext;
            Hackathon_UserContext HuContext   = HttpContext.RequestServices.GetService(typeof(Hackathon_UserContext)) as Hackathon_UserContext;
            dynamic user           = null;
            var     UserHackathons = new List <Hackathon>();

            if (ViewData["Name"] != null)
            {
                user = userContext.GetUserByUserName(ViewData["Name"].ToString());
                var UserHackathonList = HuContext.GetUserHackathons(user);
                foreach (int i in UserHackathonList)
                {
                    UserHackathons.Add(context.GetByID(i));
                }
            }


            dynamic Model = new ExpandoObject();

            Model.UserHackathonList  = UserHackathons;
            Model.NextHackathons     = context.GetNextHackathons();
            Model.PreviousHackathons = context.GetPreviousHackathons();
            Model.CurrentHackathons  = context.GetCurrentHackathons();
            return(View(Model));
        }
Exemplo n.º 2
0
        public IActionResult AddHackathon(string username, string title, string subtitle, string description, string contactMail, string contactPhone,
                                          string contactWebsite, byte[] coverPhoto, byte[] thumbnail, DateTime startDate, DateTime endDate)
        {
            ViewData["Name"] = HttpContext.Session.GetString("UName");
            ViewData["Type"] = HttpContext.Session.GetString("Type");

            Hackathon_UserContext hucontext = HttpContext.RequestServices.GetService(typeof(Hackathon_UserContext)) as Hackathon_UserContext;
            UserContext           uContext  = HttpContext.RequestServices.GetService(typeof(UserContext)) as UserContext;

            if (hucontext.AddHackathon(uContext.GetUserByUserName(username), new Hackathon {
                Title = title,
                Subtitle = subtitle,
                Description = description,
                ContactMail = contactMail,
                ContactPhone = contactPhone,
                ContactWebsite = contactWebsite,
                CoverPhoto = coverPhoto,
                Thumbnail = thumbnail,
                StartDate = startDate,
                EndDate = endDate
            }))
            {
                return(Redirect("~/Home"));
                //return Redirect($"~/Hackathon/AddProblemStatements");
            }
            return(Redirect("~/Hackathon/Add"));
        }