示例#1
0
        public ActionResult Update(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _unitOfWork.EventType.GetAllEventType();
                return(View("EventForm", viewModel));
            }

            var VetEvent = _unitOfWork.Event.GetEventWithItsAttendees(viewModel.Id);

            if (VetEvent == null)
            {
                throw new NullReferenceException();
            }

            if (VetEvent.EventOrganizerId != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }

            VetEvent.Update(viewModel.GetDateTime(), viewModel.Venue, viewModel.EventType);

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Events"));
        }
示例#2
0
        public ActionResult Update(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.Genres.GetGenres();
                return(View("EventForm", viewModel));
            }

            var @event = _unitOfWork.Events.GetEventWithAttendees(viewModel.Id);

            if (@event == null)
            {
                return(HttpNotFound());
            }

            if (@event.ArtistId != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }

            @event.Modify(viewModel.GetDateTime(), viewModel.Venue, viewModel.Genre);

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Events"));
        }
示例#3
0
        public ActionResult Create(EventFormViewModel viewModel, HttpPostedFileBase Image)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _context.EventTypes.ToList();
                return(View("EventForm", viewModel));
            }
            FileInfo sllaw = new FileInfo(Image.FileName);
            string   photo = Guid.NewGuid().ToString("N") + sllaw.Extension;

            Image.SaveAs(Server.MapPath("~/Content/Upload/Image/" + photo));
            viewModel.Image = photo;


            var anEvent = new Event
            {
                CreatorId   = User.Identity.GetUserId(),
                Location    = viewModel.Location,
                Description = viewModel.Description,
                Image       = photo,
                Price       = viewModel.Price,
                DateTime    = viewModel.GetDateTime(),
                EventTypeId = viewModel.EventType
            };

            _context.Events.Add(anEvent);
            _context.SaveChanges();

            return(RedirectToAction("Mine", "Events"));
        }
示例#4
0
        public ActionResult Update(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _context.Genres.ToList();
                return(View("EventForm", viewModel));
            }

            var eventMakerId  = User.Identity.GetUserId();
            var eventToUpdate = _context.Events.Single(e => e.Id == viewModel.Id && e.EventMakerId == eventMakerId);

            eventToUpdate.Update(viewModel.GetDateTime(), viewModel.Venue, viewModel.Genre);
            _context.SaveChanges();

            return(RedirectToAction("Mine", "Events"));
        }
        public ActionResult Update(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _context.EventTypes.ToList();
                return(View("EventForm", viewModel));
            }

            var UserId = User.Identity.GetUserId();

            var eEvent = _context.Events
                         .Include(e => e.Attendances.Select(a => a.Attendee))
                         .Single(e => e.Id == viewModel.Id && e.InstructorId == UserId);

            eEvent.Modify(viewModel.GetDateTime(), viewModel.Description, viewModel.EventType);

            _context.SaveChanges();
            return(RedirectToAction("Mine", "Events"));
        }
示例#6
0
        public ActionResult Create(EventFormViewModel eventViewModel)
        {
            if (!ModelState.IsValid)
            {
                eventViewModel.Genres = _context.Genres.ToList();
                return(View("Create", eventViewModel));
            }
            var gigEvent = new Event
            {
                ArtistId = User.Identity.GetUserId(),
                DateTime = eventViewModel.GetDateTime(),
                GenreId  = eventViewModel.Genre,
                Venue    = eventViewModel.Venue
            };

            _context.Events.Add(gigEvent);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _context.EventTypes.ToList();
                return(View("EventForm", viewModel));
            }

            var newEvent = new Event
            {
                InstructorId = User.Identity.GetUserId(),
                DateTime     = viewModel.GetDateTime(),
                EventTypeId  = viewModel.EventType,
                Description  = viewModel.Description
            };

            _context.Events.Add(newEvent);
            _context.SaveChanges();
            return(RedirectToAction("Mine", "Events"));
        }
示例#8
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Categories = _context.Categories.ToList();
                return(View("Create", viewModel));
            }
            var event1 = new Event
            {
                OrganizerId = User.Identity.GetUserId(),
                DateTime    = viewModel.GetDateTime(),
                CategoryId  = viewModel.Category,
                Venue       = viewModel.Venue
            };

            _context.Events.Add(event1);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
示例#9
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _unitOfWork.EventType.GetAllEventType();
                return(View("EventForm", viewModel));
            }

            var VetEvent = new Event
            {
                EventOrganizerId = User.Identity.GetUserId(),
                DateTime         = viewModel.GetDateTime(),
                EventTypeId      = viewModel.EventType,
                Venue            = viewModel.Venue
            };

            _unitOfWork.Event.Add(VetEvent);
            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Events"));
        }
示例#10
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _context.Genres.ToList();
                return(View("Create", viewModel));
            }

            var events = new Event
            {
                ArtistId = User.Identity.GetUserId(),
                DateTime = viewModel.GetDateTime(),
                GenreId  = viewModel.Genre,
                Location = viewModel.Location
            };

            _context.Events.Add(events);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
示例#11
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _context.Genres.ToList();
                return(View("EventForm", viewModel));
            }

            var eventMakerId = User.Identity.GetUserId();
            var eventToAdd   = new Event
            {
                EventMakerId = eventMakerId,
                DateTime     = viewModel.GetDateTime(),
                GenreId      = viewModel.Genre,
                Venue        = viewModel.Venue,
            };

            _context.Events.Add((eventToAdd));
            _context.SaveChanges();
            return(RedirectToAction("Mine", "Events"));
        }
示例#12
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.Genres.GetGenres();
                return(View("EventForm", viewModel));
            }

            var @event = new Event
            {
                ArtistId = User.Identity.GetUserId(),
                DateTime = viewModel.GetDateTime(),
                GenreId  = viewModel.Genre,
                Venue    = viewModel.Venue
            };

            _unitOfWork.Events.Add(@event);
            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Events"));
        }
示例#13
0
        public ActionResult Update(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.EventTypes = _context.EventTypes.ToList();
                return(View("EventForm", viewModel));
            }
            var userId  = User.Identity.GetUserId();
            var anEvent = _context.Events.Single(e => e.Id == viewModel.Id && e.CreatorId == userId);

            anEvent.Location    = viewModel.Location;
            anEvent.Description = viewModel.Description;
            anEvent.Image       = viewModel.Image;
            anEvent.Price       = viewModel.Price;
            anEvent.DateTime    = viewModel.GetDateTime();
            anEvent.EventTypeId = viewModel.EventType;

            _context.SaveChanges();

            return(RedirectToAction("Mine", "Events"));
        }
示例#14
0
        public ActionResult Create(EventFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Topics = _context.Topics.ToList();
                return(View("Create", viewModel)); // Create View, viewModel - so that
                //all values will be in there with validation messages
            }


            var event1 = new Event()
            {
                SpeakerId = User.Identity.GetUserId(),
                TopicId   = viewModel.Topic,
                DateTime  = viewModel.GetDateTime(),
                Venue     = viewModel.Venue
            };

            _context.Events.Add(event1);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }