示例#1
0
        public bool AddNewEvent(EventFormViewModel model)
        {
            var imageUrl = _uploadService.Upload(model.Image);

            var transaction = _db.Database.BeginTransaction();

            var @event = new Events
            {
                DateEng = model.EnglishDate,
                DateNep = model.NepaliDate
            };

            _db.Events.Add(@event);
            _db.SaveChanges();

            var timeline = new Timeline
            {
                Description = model.Description,
                EventLink   = model.Link,
                Title       = model.Title,
                EventRefId  = @event.Id,
                ImageLink   = imageUrl
            };

            _db.Timeline.Add(timeline);
            _db.SaveChanges();

            transaction.Commit();
            return(true);
        }
示例#2
0
        // GET: Events/Edit/1
        public async Task <ActionResult> Edit(int id)
        {
            var loggedInUser = await GetCurrentUserAsync();

            var eventTypes = await _context.EventType.Select(e => new SelectListItem()
            {
                Text  = e.Name,
                Value = e.Id.ToString()
            })
                             .ToListAsync();

            var eventt = await _context.Event.FirstOrDefaultAsync(e => e.Id == id);

            var viewModel = new EventFormViewModel()
            {
                Name             = eventt.Name,
                City             = eventt.City,
                Address          = eventt.Address,
                SecondaryAddress = eventt.SecondaryAddress,
                ImagePath        = eventt.ImagePath,
                EventTypeId      = eventt.EventTypeId,
                EventTypeOptions = eventTypes,
            };

            if (eventt.ApplicationUserId != loggedInUser.Id)
            {
                return(NotFound());
            }

            return(View(viewModel));
        }
示例#3
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"));
        }
示例#4
0
        public ActionResult Save(Event @event)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new EventFormViewModel(@event)
                {
                    EventTypes = _context.EventTypes.ToList()
                };

                return(View("EventForm", viewModel));
            }

            if (@event.Id == 0)
            {
                _context.Events.Add(@event);
            }
            else
            {
                var eventInDb = _context.Events.Single(e => e.Id == @event.Id);

                eventInDb.Name        = @event.Name;
                eventInDb.Description = @event.Description;
                eventInDb.StartTime   = @event.StartTime;
                eventInDb.EndTime     = @event.EndTime;
                eventInDb.EventTypeId = @event.EventTypeId;
            }
            _context.SaveChanges();

            return(RedirectToAction("Index", "Event"));
        }
示例#5
0
        public ActionResult Edit(int id)
        {
            var evento = _unitOfWork.Events.GetEvent(id);

            if (evento == null)
            {
                return(HttpNotFound());
            }

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

            var viewModel = new EventFormViewModel
            {
                Heading = "Edit a Event",
                Id      = evento.Id,
                Genres  = _unitOfWork.Genre.GetGenres(),
                Date    = evento.DateTime.ToString("d MMM yyyy"),
                Time    = evento.DateTime.ToString("HH:mm"),
                Venue   = evento.Venue,
                Genre   = evento.GenreId
            };

            return(View("EventForm", viewModel));
        }
示例#6
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"));
        }
示例#7
0
        public ActionResult Save(Event upcomingEvent)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new EventFormViewModel
                {
                    Event = upcomingEvent
                };
                return(View("EventForm", viewModel));
            }
            else
            {
                if (!IsInEvents(upcomingEvent.Id))
                {
                    _context.Events.Add(upcomingEvent);
                }

                else
                {
                    var eventInDb = _context.Events.Single(e => e.Id == upcomingEvent.Id);
                    eventInDb.Name            = upcomingEvent.Name;
                    eventInDb.DateOfEvent     = upcomingEvent.DateOfEvent;
                    eventInDb.NumberOfMembers = upcomingEvent.NumberOfMembers;
                    eventInDb.Id = upcomingEvent.Id;
                }
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Events"));
        }
示例#8
0
        public async Task <ActionResult> Edit(int id, EventFormViewModel eventFormView)
        {
            try
            {
                var user = await GetCurrentUserAsync();

                var events = new Event()
                {
                    Id                = id,
                    Name              = eventFormView.Name,
                    City              = eventFormView.City,
                    Address           = eventFormView.Address,
                    SecondaryAddress  = eventFormView.SecondaryAddress,
                    ImagePath         = eventFormView.ImagePath,
                    ApplicationUserId = user.Id,
                    EventTypeId       = eventFormView.EventTypeId,
                };

                _context.Event.Update(events);
                await _context.SaveChangesAsync();

                // TODO: Add update logic here

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
示例#9
0
        public ActionResult Save(EventFormViewModel model)
        {
            /* if (!ModelState.IsValid)
             *
             *   return View("EventForm", new EventFormViewModel {
             *       Event = eventt
             *   });*/
            var eventt = model.Event;

            if (eventt.Id == 0)
            {
                _context.Events.Add(eventt);
            }
            else
            {
                var eventtInDb = _context.Events.Single(e => e.Id == eventt.Id);
                eventtInDb.Name        = eventt.Name;
                eventtInDb.Description = eventt.Description;
                eventtInDb.StartDate   = eventt.StartDate;
                eventtInDb.FinishDate  = eventt.FinishDate;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Event"));
        }
示例#10
0
        public ActionResult Save(Event Event)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new EventFormViewModel
                {
                    Event    = Event,
                    Subjects = _context.Subjects.ToList()
                };
                return(View("EventForm", viewModel));
            }

            if (Event.Id == 0)
            {
                _context.Events.Add(Event);
            }
            else
            {
                var eventInDb = _context.Events.Single(e => e.Id == Event.Id);

                eventInDb.Name        = Event.Name;
                eventInDb.SubjectId   = Event.SubjectId;
                eventInDb.Date        = Event.Date;
                eventInDb.Location    = Event.Location;
                eventInDb.Description = Event.Description;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Event"));
        }
示例#11
0
        public async Task <IActionResult> Edit(int id, EventFormViewModel model)
        {
            try
            {
                await this.eventService.EditAsync(
                    id,
                    model.Title,
                    model.Content,
                    model.City,
                    model.Address,
                    model.ImageUrl,
                    model.StartDate,
                    model.EndDate);

                this.TempData.AddSuccessMessage(string.Format(WebConstants.SuccessfullyAddedEvent, model.Title));
                return(this.RedirectToAction(nameof(Index)));
            }
            catch (InvalidOperationException ex)
            {
                this.TempData.AddErrorMessage(ex.Message);
                return(this.RedirectToAction(nameof(Edit), new { id }));
            }
            catch (Exception ex)
            {
                this.TempData.AddErrorMessage(ex.Message);
                return(this.RedirectToAction(nameof(Edit), new { id }));
            }
        }
示例#12
0
        public ActionResult Edit(int id)
        {
            var vetEvents = _unitOfWork.Event.GetMyEvent(id, User.Identity.GetUserId());

            if (vetEvents == null)
            {
                return(HttpNotFound());
            }

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

            var viewModel = new EventFormViewModel
            {
                Id         = vetEvents.Id,
                EventTypes = _unitOfWork.EventType.GetAllEventType(),
                EventType  = vetEvents.EventTypeId,
                Venue      = vetEvents.Venue,
                Date       = vetEvents.DateTime.ToString("d MMM yyyy"),
                Time       = vetEvents.DateTime.ToString("HH:mm"),
                Title      = "Edit",
            };

            return(View("EventForm", viewModel));
        }
        public ActionResult Save(EventFormViewModel eventFormViewModel)
        {
            if (eventFormViewModel.Event.EventId == 0)
            {
                eventFormViewModel.Event.EventLocation = eventFormViewModel.EventLocation;
                eventFormViewModel.Event.Members       = _context.Members
                                                         .Where(m => eventFormViewModel.SelectedMembers.Contains(m.MemberId)).ToList();
                _context.Events.Add(eventFormViewModel.Event);
            }
            else
            {
                var eventInDb = _context.Events.Single(e => e.EventId == eventFormViewModel.Event.EventId);
                eventInDb.Name        = eventFormViewModel.Event.Name;
                eventInDb.EventDate   = eventFormViewModel.Event.EventDate;
                eventInDb.Description = eventFormViewModel.Event.Description;

                var eventLocationInDb =
                    _context.EventLocations.Single(e => e.EventId == eventFormViewModel.Event.EventId);
                eventLocationInDb.Building = eventFormViewModel.EventLocation.Building;
                eventLocationInDb.Street   = eventFormViewModel.EventLocation.Street;
                eventLocationInDb.TownCity = eventFormViewModel.EventLocation.TownCity;
                eventLocationInDb.County   = eventFormViewModel.EventLocation.County;
                eventLocationInDb.Postcode = eventFormViewModel.EventLocation.Postcode;

                var updatedEventMembers = _context.Members
                                          .Where(m => eventFormViewModel.SelectedMembers.Contains(m.MemberId)).ToList();
                eventInDb.Members
                .Clear();     // Might be a more efficient way to do this but manually comparing causes a DataReader exception
                eventInDb.Members = updatedEventMembers;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Events"));
        }
示例#14
0
        public ActionResult Edit(int id)
        {
            var @event = _unitOfWork.Events.GetEvent(id);

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

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

            var viewModel = new EventFormViewModel
            {
                Heading = "Etkinlik Düzenle",
                Id      = @event.Id,
                Genres  = _unitOfWork.Genres.GetGenres(),
                Date    = @event.DateTime.ToString("d MMM yyyy"),
                Time    = @event.DateTime.ToString("HH:mm"),
                Genre   = @event.GenreId,
                Venue   = @event.Venue
            };

            return(View("EventForm", viewModel));
        }
示例#15
0
        public ActionResult Save(Event evnt)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new EventFormViewModel(evnt)
                {
                    EventCategories = _cms.EventCategories.ToList(),
                    Locations       = _cms.Locations.ToList(),
                    Organisers      = _cms.Organisers.ToList()
                };
                return(View("EventForm", viewModel));
            }

            if (evnt.EventId == 0)
            {
                _cms.Events.Add(evnt);
            }
            else
            {
                var evntInDb = _cms.Events.Single(c => c.EventId == evnt.EventId);
                evntInDb.Priority        = evnt.Priority;
                evntInDb.Details         = evnt.Details;
                evntInDb.StartTime       = evnt.StartTime;
                evntInDb.EndTime         = evnt.EndTime;
                evntInDb.LocationId      = evnt.LocationId;
                evntInDb.OrganiserId     = evnt.OrganiserId;
                evntInDb.EventCategoryId = evnt.EventCategoryId;
            }
            _cms.SaveChanges();
            return(RedirectToAction("Index", "Events"));
        }
示例#16
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"));
        }
示例#17
0
        public IActionResult EditEventForm(EventFormViewModel vm)
        {
            var model = Mapper.Map <EventFormViewModel, EventFormData>(vm);

            model = eventFormsRepo.Update(model);
            ViewData["Message"] = string.Format("Successfully Updated: {0}", model.FormName);
            return(View("Result"));
        }
示例#18
0
        public ActionResult New()
        {
            var viewModel = new EventFormViewModel {
                Event = new Event()
            };

            return(View("EventForm", viewModel));
        }
示例#19
0
        public ActionResult CreateEvent(EventFormViewModel Event)
        {
            Event addingEvent = Mapper.Map <EventFormViewModel, Event>(Event);

            eventService.CreateEvent(addingEvent);
            eventService.SaveEvent();
            return(View(Event));
        }
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel()
            {
                Genres = _db.Genres.ToList()
            };

            return(View(viewModel));
        }
示例#21
0
        // GET: Events
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {   //ienumerable list = new dbcontext.model-type.toList
                EventTypes = _context.EventTypes.ToList()
            };

            return(View(viewModel));
        }
示例#22
0
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {
                Topics = _context.Topics.ToList()
            };

            return(View(viewModel));
        }
示例#23
0
        public EventFormViewModel MapEventToEventFormViewModel(Event @event)
        {
            var eventFormViewModel = new EventFormViewModel()
            {
                EventFormDto = MapEventToEventFormDto(@event)
            };

            return(eventFormViewModel);
        }
示例#24
0
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {
                EventTypes = _unitOfWork.EventType.GetAllEventType(),
                Title      = "Add an Event"
            };

            return(View("EventForm", viewModel));
        }
示例#25
0
        public ActionResult New()
        {
            var eventTypes = _context.EventTypes.ToList();
            var viewModel  = new EventFormViewModel
            {
                EventTypes = eventTypes
            };

            return(View("EventForm", viewModel));
        }
示例#26
0
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {
                Genres  = _unitOfWork.Genres.GetGenres(),
                Heading = "Etkinlik Ekle"
            };

            return(View("EventForm", viewModel));
        }
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {
                EventTypes = _context.EventTypes.ToList(),
                Heading    = "Add an Event"
            };

            return(View("EventForm", viewModel));
        }
示例#28
0
        public ActionResult Create()
        {
            var viewModel = new EventFormViewModel
            {
                Heading = "Add a Event",
                Genres  = _unitOfWork.Genre.GetGenres()
            };

            return(View("EventForm", viewModel));
        }
        public ActionResult Details(int id = 0)
        {
            var viewModel = new EventFormViewModel(id);

            if (viewModel.ID == -1)
            {
                return(HttpNotFound());
            }
            return(View("EventDetails", viewModel));
        }
示例#30
0
        public IActionResult Create(EventFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _eventService.AddNewEvent(model);
            return(Content("Done"));
        }