public IActionResult CreateEvent(NewEventViewModel model) { if (ModelState.IsValid) { Event NewEvent = new Event { Title = model.Title, EventDate = model.EventDate, EventTime = model.EventTime, Duration = model.Duration, DurationType = model.DurationType, Description = model.Description, CreatedById = (int)HttpContext.Session.GetInt32("UserId"), CreatedByFirstName = (string)HttpContext.Session.GetString("UserAlias"), CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, }; _context.Add(NewEvent); _context.SaveChanges(); return(RedirectToAction("Main", "Event")); } else { return(View("NewEvent")); } }
public NewEventView(object parameter) { InitializeComponent(); Parameter = parameter; BindingContext = new NewEventViewModel(); }
public async Task <IActionResult> EditEvent(NewEventViewModel evm, int ID) { var user = await userManager.GetUserAsync(HttpContext.User); ViewBag.genres = context.Genres.ToList(); var events = context.Events.ToList(); Event e = events.FirstOrDefault(x => x.EventID == ID); if (e.Artist.UserName == user.UserName) { e.EventName = evm.EventName; e.Artist = user; e.GenreID = evm.GenreID; e.Time = evm.Time; e.Venue = evm.Venue; ViewBag.Notification = "Event Data Changed."; } else { ViewBag.Notification = "You do not have access to edit this event."; } context.SaveChanges(); return(RedirectToAction("EventList")); }
public ActionResult AddEvent() { var vm = new NewEventViewModel(); vm.SetSelectListItems(); return(View(vm)); }
public NewEventPage(Client client) { InitializeComponent(); var eventViewModel = new NewEventViewModel(client); eventViewModel.Client = client; BindingContext = eventViewModel; }
public NewEventPage(ObservableCollection <Event> events) { InitializeComponent(); NewEventViewModel viewModel = new NewEventViewModel(events); BindingContext = viewModel; }
public ActionResult AddEvent(NewEventViewModel vm, HttpPostedFileBase file) { var repo = RepositoryFactory.CreateRepository(); var e = new Event { Name = vm.Name, Description = vm.Description, StartDate = vm.DateStart, EndDate = vm.DateEnd }; //if (vm.IsAllDay) //{ // if (vm.DateStart.HasValue) // e.StartDate = vm.DateStart.Value; // if (vm.DateEnd.HasValue) // e.EndDate = vm.DateEnd.Value; //} //else //{ // if (vm.DateTimeStart.HasValue) // { // e.StartDate = vm.DateTimeStart.Value; // e.StartTime = vm.DateTimeStart.Value; // } // if (vm.DateTimeEnd.HasValue) // e.EndTime = vm.DateTimeEnd.Value; //} if (!string.IsNullOrEmpty(vm.VenueName)) { e.Venue = new Venue { Name = vm.VenueName, Contact = new ContactInfo { StreetAddress = vm.VenueStreetAddress, City = vm.VenueCity, State = vm.VenueState, Zip = vm.VenueZip, Phone = vm.VenuePhone, Email = vm.VenueEmail } }; repo.AddContact(e.Venue.Contact); e.Venue = repo.AddVenue(e.Venue); } if (e.Venue == null && vm.VenueId != null) { e.Venue = repo.GetVenueById(vm.VenueId.Value); } e.ImgPath = UploadImage(file); repo.AddEvent(e); return(RedirectToAction("ManageEvents", "Admin")); }
//Called when an event is being edited public NewEventPage(Event original) { InitializeComponent(); Title = "Edit Event"; viewModel = new NewEventViewModel(original); BindingContext = viewModel; NewEventPageButton.Clicked += Save_Edit_Clicked; }
public ViewModelLocator() { _navigationService = new NavigationService(); _repository = new ApiRepository(); EventsViewModel = new EventsViewModel(_navigationService, _repository); ParticipantsViewModel = new ParticipantsViewModel(_navigationService, _repository); EventDetailViewModel = new EventDetailViewModel(_navigationService, _repository); NewEventViewModel = new NewEventViewModel(_navigationService, _repository); }
//Called when a new event is being created public NewEventPage() { InitializeComponent(); Title = "New Event"; Event ev = new Event(); viewModel = new NewEventViewModel(ev); BindingContext = viewModel; NewEventPageButton.Clicked += Save_Clicked; }
protected override void OnAppearing() { base.OnAppearing(); NewEventViewModel viewModel = (NewEventViewModel)BindingContext; if (viewModel != null) { viewModel.OnAppearing(Parameter); } }
public ActionResult EditEvent(int id) { var repo = RepositoryFactory.CreateRepository(); var e = repo.GetEventById(id); var vm = new NewEventViewModel { Name = e.Name, Description = e.Description, EventId = e.EventId, VenueId = e.Venue.VenueId }; vm.SetSelectListItems(); return(View(vm)); }
public ViewModelLocator() { _navigationService = new NavigationService(); _dataService = new DataService(new UserRepository(), new MenuRepository(), new DishRepository(), new CustomerRepository(), new DelivererRepository(), new EventRepository(), new IngredientRepository()); CustomerOverviewViewModel = new CustomerOverviewViewModel(_navigationService, _dataService); DelivererOverviewViewModel = new DelivererOverviewViewModel(_navigationService, _dataService); EventOverviewViewModel = new EventOverviewViewModel(_navigationService, _dataService); LoginViewModel = new LoginViewModel(_navigationService, _dataService); MainViewModel = new MainViewModel(_navigationService, _dataService); EditCustomerViewModel = new EditCustomerViewModel(_navigationService, _dataService); EditDelivererViewModel = new EditDelivererViewModel(_navigationService, _dataService); EditEventViewModel = new EditEventViewModel(_navigationService, _dataService); EditStaffViewModel = new EditStaffViewModel(_navigationService, _dataService); NewDelivererViewModel = new NewDelivererViewModel(_navigationService, _dataService); NewDishViewModel = new NewDishViewModel(_navigationService, _dataService); NewEventViewModel = new NewEventViewModel(_navigationService, _dataService); NewMenuViewModel = new NewMenuViewModel(_navigationService, _dataService); NewStaffViewModel = new NewStaffViewModel(_navigationService, _dataService); StaffViewModel = new StaffViewModel(_navigationService, _dataService); }
public ActionResult Post([FromBody] NewEventViewModel newEvent) { if (!ModelState.IsValid) { return(BadRequest()); } var id = _eventRepo.GetNextId(); var eve = new Event(id, newEvent.Name, newEvent.Description, newEvent.Price, newEvent.DateTime, newEvent.AdditionalInformation); try { _eventRepo.Add(eve); var viewModel = new EventDetailsViewModel(eve.Id, eve.Name, eve.Description, eve.Date, eve.Price, eve.AdditionalInformation); return(CreatedAtRoute("GetById", new { id = eve.Id }, viewModel)); } catch (Exception) { return(StatusCode(500, "There was an error handling your request.")); } }
public IActionResult NewCalendarEvent(NewEventViewModel vm) { // Validate is admin if (!_credentialHoldingService.IsAdmin) { return(RedirectToRoute(new { controller = "Home", action = "Index" })); } string errormsg; _context.CalendarEventRepository.AddEvent(vm.Date, vm.Title, out errormsg); if (errormsg != "") { var newVm = _vmFactory.Resolve <NewEventViewModel>(); newVm.ErrorMessage = errormsg; return(View("CreateNewEvent", newVm)); } return(RedirectToAction("Calendar")); }
public async Task <ActionResult> CreateEvent(NewEventViewModel model) { var eventTime = new EventTime { StartTime = model.StartDateTime, DurationInMinutes = model.DurationHours * 60 + model.DurationMinutes }; var scheduler = new EventScheduler { IsTimeSet = model.ScheduleNow, ProposedTimes = new List <EventTime>(), Responses = new List <EventSchedulerResponse>(), }; var location = new Location { NameOrAddress = model.Location, Latitude = model.Latitude, Longitude = model.Longitude }; var newEvent = new Event { Creator = await _userService.FindUserById(User.Identity.GetUserId()), Name = model.Name, Description = model.Description, Location = location, EventTime = model.ScheduleNow ? eventTime : null, Scheduler = scheduler, CreationTime = DateTime.UtcNow }; _eventService.Create(newEvent); _unitOfWork.SaveChanges(); return(RedirectToAction("Index", "EventFeed")); }
public ActionResult Put(int id, [FromBody] NewEventViewModel updatedEvent) { if (!ModelState.IsValid) { return(BadRequest()); } try { var existing = _eventRepo.Get(id); if (existing == null) { return(NotFound()); } var eve = new Event(id, updatedEvent.Name, updatedEvent.Description, updatedEvent.Price, updatedEvent.DateTime, updatedEvent.AdditionalInformation); _eventRepo.Update(eve); return(Ok(eve)); } catch (Exception) { return(StatusCode(500, "There was an error handling your request.")); } }
public ActionResult Create() { NewEventViewModel model = new NewEventViewModel(); return(View(model)); }
public AddEventCommand(NewEventViewModel viewModel) { this.viewModel = viewModel; }
public NewEventPage() { InitializeComponent(); this._viewModel = new NewEventViewModel(); BindingContext = this._viewModel; }