Beispiel #1
0
        public ActionResult Save(EventAddress eventAddress, ExhibitorInput exhibitorInput)
        {
            var userAuthenticated = userService.GetUser(User.Identity.Name);

            if (userAuthenticated == null || !userAuthenticated.IsInRole("Admin"))
            {
                return(null);
            }

            if (eventAddress == null)
            {
                return(null);
            }

            var @event = eventService.GetEvent(eventAddress);

            var existingExhibitor = exhibitorService.GetExhibitor(eventAddress, exhibitorInput.Name);
            var exhibitorId       = existingExhibitor != null ? existingExhibitor.ID : Guid.Empty;
            var exhibitorCreated  = existingExhibitor != null ? existingExhibitor.CreatedDate : DateTime.Now;

            var exhibitor = new Exhibitor(exhibitorId, @event.ID, exhibitorInput.Name,
                                          exhibitorInput.Description, exhibitorInput.SiteUrl,
                                          exhibitorInput.LogoUrl, exhibitorInput.ParticipantLevel,
                                          exhibitorInput.ContactName, exhibitorInput.ContactEmail,
                                          exhibitorInput.Location, exhibitorInput.Tags,
                                          exhibitorCreated,
                                          DateTime.UtcNow);

            ModelResult <Exhibitor> results = exhibitorService.SaveExhibitor
                                                  (eventAddress, exhibitor);

            if (!results.IsValid)
            {
                ModelState.AddModelErrors(results.ValidationState);
            }

            return(new RedirectResult(Url.EditExhibitor(exhibitor.Name.CleanSlug())));
        }