Beispiel #1
0
        public ActionResult CreateItem(DetailsEventViewModel model)
        {
            int id   = model.Id;
            var evnt = service.FindEventById(model.Id);

            CreateItemViewModel viewModel = new CreateItemViewModel
            {
                EventId     = id,
                Title       = "",
                Description = ""
            };

            List <SelectListItem> categories = new List <SelectListItem>();

            foreach (var item in evnt.Components)
            {
                if (item is Category)
                {
                    categories.Add(new SelectListItem {
                        Text = item.Title, Value = item.Id.ToString()
                    });
                }
            }

            viewModel.Categories = categories;

            return(View(viewModel));
        }
Beispiel #2
0
        public IActionResult Details(int id)
        {
            var myEventTowns = this.eventService.GetEventTowns(id);

            var myEventParticipants = this.eventService.GetEventParticipants(id);

            var myEvent = this.eventService.GetEvent(id);

            if (myEvent == null)
            {
                return(this.Redirect("/"));
            }

            var model = new DetailsEventViewModel
            {
                Id           = myEvent.Id,
                Name         = myEvent.Name,
                Description  = myEvent.Description,
                EventDate    = myEvent.EventDate,
                Participants = myEventParticipants,
                Towns        = myEventTowns,
            };

            return(this.View(model));
        }
Beispiel #3
0
        public ActionResult Details(int?id)
        {
            if (Session["LoggedIn"] == null)
            {
                return(RedirectToAction("LogIn", "User"));
            }
            var usr = utils.Utils.GetUser(Session);


            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var e = service.FindEventById(id.Value);

            var inviteString = (usr.Id == e.Admin.Id) ? service.GetInviteString(e, usr) : null;


            DetailsEventViewModel ev = new DetailsEventViewModel
            {
                Id                  = e.Id,
                Date                = e.Datetime.Date,
                Description         = e.Description,
                IsPublic            = e.IsPublic,
                Location            = e.Location,
                NumOfParticipants   = e.NumOfParticipants,
                PriceFrom           = e.PriceFrom,
                PriceTo             = e.PriceTo,
                Time                = new TimeSpan(e.Datetime.Hour, e.Datetime.Minute, e.Datetime.Second),
                Title               = e.Title,
                InviteString        = inviteString,
                IsAlreadyRegistered = service.IsRegisteredToEvent(usr, e)
            };

            ComponentModel cModel = new ComponentModel();

            foreach (var item in e.Components)
            {
                if (item.Parent == null)
                {
                    cModel.LevelOneList.Add(new SelectListItem
                    {
                        Text  = item.Title,
                        Value = item.Id.ToString()
                    });
                }
            }

            ev.ComponentModel = cModel;

            return(View(ev));
        }
Beispiel #4
0
        public ActionResult SignUp(DetailsEventViewModel model)
        {
            User u = utils.Utils.GetUser(Session);

            if (u == null)
            {
                return(RedirectToAction("LogIn", "User"));
            }

            try
            {
                service.SignUpForEvent(u.Email, model.Id);
            }
            catch (FaultException fe)
            {
                ViewBag.ErrorMsg = fe.Message;
                return(View());
            }

            return(RedirectToAction("SignUpSuccess"));
        }
Beispiel #5
0
        public DetailsEventViewModel CreateDetailsForEvent(Event e, User usr)
        {
            ComponentModel cModel = new ComponentModel();

            cModel.EventId = e.Id;
            foreach (var item in e.Components)
            {
                if (item.Parent == null)
                {
                    cModel.LevelOneList.Add(new SelectListItem
                    {
                        Text  = item.Title,
                        Value = item.Id.ToString()
                    });
                }
            }

            var isAlreadyRegistered = service.IsRegisteredToEvent(utils.Utils.GetUser(Session), e);

            DetailsEventViewModel ev = new DetailsEventViewModel
            {
                ComponentModel      = cModel,
                Date                = e.Datetime.Date,
                Description         = e.Description,
                Id                  = e.Id,
                InviteString        = (usr.Id == e.Admin.Id) ? service.GetInviteString(e, usr) : null,
                IsPublic            = e.IsPublic,
                Location            = e.Location,
                NumOfParticipants   = e.NumOfParticipants,
                PriceFrom           = e.PriceFrom,
                PriceTo             = e.PriceTo,
                Time                = e.Datetime.TimeOfDay,
                Title               = e.Title,
                IsAlreadyRegistered = isAlreadyRegistered
            };

            return(ev);
        }
Beispiel #6
0
        public ActionResult CreateCategory(DetailsEventViewModel model)
        {
            User u = (User)Session["User"];

            if (u == null)
            {
                return(RedirectToAction("LogIn", "User"));
            }
            int id   = model.Id;
            var evnt = service.FindEventById(model.Id);

            CreateComponentViewModel viewModel = new CreateComponentViewModel
            {
                EventId     = id,
                Title       = "",
                Description = ""
            };

            List <SelectListItem> categories = new List <SelectListItem>();

            categories.Add(new SelectListItem {
                Text = "Ingen", Value = null
            });

            foreach (var item in evnt.Components)
            {
                if (item is Category && item.Parent == null)
                {
                    categories.Add(new SelectListItem {
                        Text = item.Title, Value = item.Id.ToString()
                    });
                }
            }

            viewModel.Categories = categories;

            return(View(viewModel));
        }
Beispiel #7
0
        public ActionResult SignUpForItem(ComponentModel model)
        {
            var usr = utils.Utils.GetUser(Session);

            if (usr == null)
            {
                return(RedirectToAction("LogIn", "User"));
            }

            try
            {
                if (model.CurrentLevelTwoItemId != null)
                {
                    service.SignUpForItem(usr.Email, (int)model.CurrentLevelTwoItemId);
                    ViewBag.SuccessMessage = "Registrering er nu opdateret.";
                }
                else if (model.CurrentLevelThreeItemId != null)
                {
                    service.SignUpForItem(usr.Email, (int)model.CurrentLevelThreeItemId);
                    ViewBag.SuccessMessage = "Registrering er nu opdateret.";
                }

                Event e = service.FindEventById(model.EventId);
                DetailsEventViewModel ev = CreateDetailsForEvent(e, usr);


                return(View("Details", ev));
            }
            catch (FaultException fax)
            {
                Event e = service.FindEventById(model.EventId);
                DetailsEventViewModel ev = CreateDetailsForEvent(e, usr);

                ViewBag.Message = fax.Message;
                return(View("Details", ev));
            }
        }
Beispiel #8
0
        public ActionResult Details(int?eventId, int?LevelOneId, int?LevelTwoId, int?LevelThreeId)
        {
            var e = service.FindEventById(eventId.Value);

            var isAlreadyRegistered = service.IsRegisteredToEvent(utils.Utils.GetUser(Session), e);

            DetailsEventViewModel ev = new DetailsEventViewModel
            {
                Id                  = e.Id,
                Date                = e.Datetime.Date,
                Description         = e.Description,
                IsPublic            = e.IsPublic,
                Location            = e.Location,
                NumOfParticipants   = e.NumOfParticipants,
                PriceFrom           = e.PriceFrom,
                PriceTo             = e.PriceTo,
                Time                = new TimeSpan(e.Datetime.Hour, e.Datetime.Minute, e.Datetime.Second),
                Title               = e.Title,
                IsAlreadyRegistered = isAlreadyRegistered
            };

            ComponentModel cModel = new ComponentModel();

            cModel.EventId = e.Id;
            foreach (var item in e.Components)
            {
                if (item.Parent == null)
                {
                    cModel.LevelOneList.Add(new SelectListItem
                    {
                        Text  = item.Title,
                        Value = item.Id.ToString()
                    });
                }
            }

            if (LevelOneId.HasValue)
            {
                var levelTwoComponents = service.FindComponentByParentId((int)LevelOneId);
                foreach (var item in levelTwoComponents)
                {
                    cModel.LevelTwoList.Add(new SelectListItem {
                        Text = item.Title, Value = item.Id.ToString()
                    });
                }

                if (LevelTwoId.HasValue)
                {
                    cModel.CurrentLevelTwoItemId = null;
                    if (levelTwoComponents.SingleOrDefault(i => i.Id == (int)LevelTwoId) is Item)
                    {
                        cModel.CurrentLevelTwoItemId   = LevelTwoId;
                        cModel.CurrentLevelThreeItemId = null;
                    }

                    var levelThreeComponents = service.FindComponentByParentId((int)LevelTwoId);
                    foreach (var item in levelThreeComponents)
                    {
                        cModel.LevelThreeList.Add(new SelectListItem {
                            Text = item.Title, Value = item.Id.ToString()
                        });
                    }

                    if (!(levelTwoComponents.SingleOrDefault(i => i.Id == (int)LevelTwoId) is Item))
                    {
                        if (LevelThreeId.HasValue)
                        {
                            if (levelThreeComponents.SingleOrDefault(i => i.Id == (int)LevelThreeId) is Item)
                            {
                                cModel.CurrentLevelThreeItemId = LevelThreeId;
                                cModel.CurrentLevelTwoItemId   = null;
                            }
                        }
                    }
                }
            }

            ev.ComponentModel = cModel;

            return(View(ev));
        }