Exemplo n.º 1
0
        // GET: Event/Create
        public ActionResult Create()
        {
            var userService = new ELSO.Services.PersonService();
            var pin         = User.Identity.Name.Split('\\')[1];
            var user        = userService.getUserInfobyPIN(pin);

            if (user.FirstName != null)
            {
                var index = user.FirstName.IndexOf("Contractor");
                if (index != -1)
                {
                    user.FirstName = user.FirstName.Remove(index);
                }
            }

            var name = user.FirstName + " " + user.LastName;

            ViewBag.Name = name;
            ViewBag.Pin  = pin;
            return(View());
        }
Exemplo n.º 2
0
        // GET: Event/Details/id
        public ActionResult SignIn(int id)
        {
            var userService = new ELSO.Services.PersonService();
            var pin         = User.Identity.Name.Split('\\')[1];
            var domain      = User.Identity.Name.Split('\\')[0];
            var user        = userService.getUserInfobyPIN(pin);

            if (user.FirstName != null)
            {
                var index = user.FirstName.IndexOf("Contractor");
                if (index != -1)
                {
                    user.FirstName = user.FirstName.Remove(index);
                }
            }
            var name = user.FirstName + " " + user.LastName;

            ViewBag.Name = name;
            ViewBag.Pin  = pin;
            bool   IsOrganizer = false;
            bool   allowSignIn = false;
            Person userOrg     = null;
            string organizers  = null;

            EventViewModel evnt      = new EventViewModel();
            Event          evntModel = _service.GetEventByUID(id);

            if (evntModel == null)
            {
                return(View("RedirectInfo"));
            }
            evnt = EventViewModel.CreateViewModel(_service.GetEventByUID(id));
            if (userService.isAuthenticated(pin, domain))
            {
                IsOrganizer = true;
            }
            foreach (var organizer in evnt.Organizers)
            {
                if (!IsOrganizer)
                {
                    IsOrganizer = (pin == organizer) ? true : false;
                }
                userOrg = userService.getUserInfobyPIN(organizer);
                if (userOrg.FirstName != null)
                {
                    int indexORG = userOrg.FirstName.IndexOf("Contractor");
                    if (indexORG != -1)
                    {
                        userOrg.FirstName = userOrg.FirstName.Remove(indexORG);
                    }
                }
                string organizerName = userOrg.FirstName + " " + userOrg.LastName;
                organizers += String.Join(", ", organizerName) + ", ";
            }
            organizers = organizers.Substring(0, organizers.Length - 2);

            DateTime checkEndDate = Convert.ToDateTime(evnt.EndDate).AddDays(1);

            if (checkEndDate > DateTime.Now)
            {
                allowSignIn = true;
            }
            ViewBag.allowSignIn = allowSignIn;
            ViewBag.IsOrganizer = IsOrganizer;
            ViewBag.organizers  = organizers;
            // TODO : check id once data schema is complete, for now we will return an empty event even if none is found

            //ModelState.AddModelError("", "No events found, please try again or contact the event coordinator");
            return(View(evnt));
        }