public ActionResult AddEvent(string adminName) { AddEventViewModel addEventViewModel = new AddEventViewModel(); addEventViewModel.AdminNameFromView = adminName; return(View(addEventViewModel)); }
public IActionResult Add() { List <EventCategory> categories = context.Categories.ToList(); AddEventViewModel addEventViewModel = new AddEventViewModel(categories); return(View(addEventViewModel)); }
public IActionResult Add(AddEventViewModel addEventViewModel) { if (ModelState.IsValid) { EventCategory theCategory = context.EventCategories.Find(addEventViewModel.CategoryId); Event newEvent = new Event { Name = addEventViewModel.Name, Location = addEventViewModel.Location, NumAttendees = addEventViewModel.NumAttendees, Description = addEventViewModel.Description, //Type = addEventViewModel.Type, Category = theCategory, ContactEmail = addEventViewModel.ContactEmail }; //EventData.Add(newEvent); context.Events.Add(newEvent); context.SaveChanges(); return(Redirect("/Events")); } List <EventCategory> categories = context.EventCategories.ToList(); addEventViewModel.Categories = new List <SelectListItem>(); foreach (var category in categories) { addEventViewModel.Categories.Add(new SelectListItem { Value = category.Id.ToString(), Text = category.Name }); } return(View(addEventViewModel)); }
public IActionResult Add(AddEventViewModel addEventViewModel) { if (addEventViewModel.EventDays.Where(w => w.Selected)?.Count() <= 0) { TempData["AddError"] = "SelectedDays is required"; return(RedirectToAction("Add", addEventViewModel)); } if (!ModelState.IsValid) { return(RedirectToAction("Add", addEventViewModel)); } addEventViewModel.Registration.RegistrationDay = addEventViewModel.EventDays .Where(w => w.Selected).Select(s => new RegistrationDay { EventDay = new Day { Id = s.Id, Label = s.Label } }).ToList(); _registrationRepository.Add(addEventViewModel.Registration); return(RedirectToAction("Index")); }
public IActionResult Add() { // Create a blank AddEventViewModel to associate with the form in Add.cshtml AddEventViewModel addEventViewModel = new AddEventViewModel(); return(View(addEventViewModel)); }
public IActionResult Add() { IList <EventType> eventTypes = context.EventTypes.ToList(); AddEventViewModel addEventViewModel = new AddEventViewModel(eventTypes); return(View(addEventViewModel)); }
public async Task <bool> addEvent(AddEventViewModel addEvent) { Event newEvent = new Event() { Id = new Guid(), Title = addEvent.Title, Description = addEvent.Description, StartDateTime = addEvent.StartDateTime, EndDateTime = addEvent.EndDateTime }; _context.Events.Add(newEvent); foreach (var Option in addEvent.Options) { Option newOption = new Option() { Id = new Guid(), Name = Option, EventId = newEvent.Id }; _context.Options.Add(newOption); } var tm = await _context.SaveChangesAsync(); var expect = addEvent.Options.Count + 1; return(tm == expect); }
public IActionResult AddEvent(AddEventViewModel model) { if (ModelState.IsValid) { Event events = new Event { Title = model.Title, Description = model.Description, Date = model.Date, StartTime = model.StartTime, EndTime = model.EndTime, EventGuests = model.EventGuests, Fee = model.Fee.ToString(), Image = fileUpload.UploadImage(model.Image, "event_images"), Sponsor = model.Sponsor, Speaker = model.Speaker, EventCategoryId = model.EventCategoryId, LocationId = model.LocationId }; eventRepository.InsertEvent(events); eventRepository.Save(); TempData["event_created"] = $"Event { events.Title } was created successfully"; return(Redirect("index")); } GetAllEventCategories(model); GetAllLocations(model); return(View(model)); }
public IActionResult AddNewEvent(AddEventViewModel addEventViewModel) { // If all of the validation attributes are valid, create the event and store it if (ModelState.IsValid) { // This is basically a line to convert an EventViewModel to an Event model object Event newEvent = new Event { Name = addEventViewModel.Name, Description = addEventViewModel.Description, ContactEmail = addEventViewModel.ContactEmail, // Use the category ID selected in the view model to query the DB Category = dbContext.Categories.Find(addEventViewModel.CategoryId) }; // 19.3.2.2 Store (add) a new event to the DB dbContext.Events.Add(newEvent); dbContext.SaveChanges(); // Redirects back to the "events" index method above return(Redirect("/events")); } // If there are validation errors, return the same view back with the provided values return(View("Add", addEventViewModel)); }
public IActionResult Add() { //passing an instance AddEventViewModel addEventViewModel = new AddEventViewModel(); return(View(addEventViewModel)); }
public void LoadAddEventPage() { IWindowManager manager = new WindowManager(); AddEventViewModel add = new AddEventViewModel(); manager.ShowDialog(add, null, null); Reload(); }
public void LoadModifyEventPage(EventDTO customEvent) { IWindowManager manager = new WindowManager(); AddEventViewModel modify = new AddEventViewModel(customEvent); manager.ShowDialog(modify, null, null); Reload(); }
public AddEventView(string id, int day) { InitializeComponent(); this.DataContext = addEventVM = new AddEventViewModel(id, day); this.gridEvent.ItemsSource = addEventVM.lstEvent; this.cbEventType.ItemsSource = addEventVM.LstEventType; this.cbPriority.ItemsSource = addEventVM.LstEventPriority; }
public IActionResult Add() { AddEventViewModel addEventViewModel = new AddEventViewModel(); // 15.1.4 Passing in the new view model to the View method returned to the user // this will then be mapped to the form in the view return(View(addEventViewModel)); }
public Event(AddEventViewModel model) { EventId = Guid.NewGuid(); Date = model.Date; Description = model.Description; LocationId = model.LocationId; Name = model.Name; }
public IActionResult AddEvent() { AddEventViewModel model = new AddEventViewModel(); GetAllEventCategories(model); GetAllLocations(model); return(View(model)); }
public IActionResult Add() { // Add the categories from the database context to the view model AddEventViewModel addEventViewModel = new AddEventViewModel(dbContext.Categories.ToList()); // 15.1.4 Passing in the new view model to the View method returned to the user // this will then be mapped to the form in the view return(View(addEventViewModel)); }
public ActionResult AddEvent() { AddEventViewModel addEvent = new AddEventViewModel(); CheckInDbContext context = new CheckInDbContext(); ViewBag.States = context.States.ToList(); ViewBag.EventTypes = context.EventTypes.OrderBy(s => s.EventTypeName).ToList(); return(View(addEvent)); }
public async Task <IActionResult> Create(AddEventViewModel model) { if (ModelState.IsValid) { _eventService.Add(model); return(RedirectToAction("Index")); } ViewBag.Locations = new SelectList(await _locationService.GetAll(), "LocationId", "Address"); return(View(model)); }
public IActionResult AddEvent([FromForm] AddEventDto dto) { if (!_eventService.AddEvent(dto)) { ModelState.AddModelError("Image", "Image's format should be .png or .jpg"); } AddEventViewModel addEventViewModel = _mapper.Map <AddEventViewModel>(dto); return(Ok(addEventViewModel)); }
private AddEventViewModel GetAllEventCategories(AddEventViewModel model) { var eventCategories = eventRepository.GetAllEventCategories(); foreach (var categories in eventCategories) { model.EventCategories.Add(new SelectListItem { Text = categories.Title, Value = categories.Id.ToString() }); } return(model); }
public void AddEvent() { var addEventWind = new AddEventViewModel(); if (WindowManager.ShowDialog(addEventWind).Value == true) { EventControls.Add(new Label() { Content = "Hey there" }); } }
private AddEventViewModel GetAllLocations(AddEventViewModel model) { var locations = locationRepository.GetAll(); foreach (var location in locations) { model.Locations.Add(new SelectListItem { Text = location.Title, Value = location.Id.ToString() }); } return(model); }
public ActionResult Add(int id) { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage rules"))) { return(new HttpUnauthorizedResult()); } var viewModel = new AddEventViewModel { Id = id, Events = _rulesManager.DescribeEvents() }; return(View(viewModel)); }
public AddEventViewModelTests() { eventsRepositoryMock = new Mock <IEventsRepository>(); eventsRepositoryMock .Setup(er => er.GetAllUsersAvailableBetweenDates(It.IsAny <DateTime>(), It.IsAny <DateTime>())) .Returns(new List <User>()); currentUser = new User() { UserId = 1, Name = "pedro" }; addEventViewModel = new AddEventViewModel(eventsRepositoryMock.Object, currentUser); }
public async Task <IActionResult> AddEvent(AddEventViewModel addEvent) { if (!ModelState.IsValid) { return(Redirect("AddEvent")); } var result = await _poolingService.addEvent(addEvent); if (!result) { return(BadRequest("Some thing Went Wrong")); } return(Redirect("Index")); }
public AddEventViewModel CreateEvent() { using (var _db = new RMDBContext()) { var courseRepo = new CourseRepository(); var anEvent = new AddEventViewModel(); { anEvent.Courses = courseRepo.GetCourses(); }; return(anEvent); } }
public IActionResult AddEvent([FromBody] AddEventViewModel viewModel) { var @event = new Event { Name = viewModel.Name, Description = viewModel.Description }; try { return(Ok(_eventRepository.Add(@event, viewModel.EstablishmentId))); } catch (EventException e) { return(BadRequest(new { message = e.Message })); } }
public IActionResult AddEvent() { var organizationId = identityRepository.GetOrganizationId(userManager.GetUserId(HttpContext.User)); var organization = identityRepository.GetOrganization(organizationId); if (organization == null) { return(Unauthorized()); } var model = new AddEventViewModel() { Organization = organization }; return(View(model)); }
public MainWindowViewModel() { eventsRepository = new EventsRepository(); currentUser = eventsRepository.GetUserByName("cal"); SignInViewModel.ChangeUserCallback switchCurrentUserDelegate = SwitchCurrentUser; var signInViewModel = new SignInViewModel(eventsRepository, switchCurrentUserDelegate); WeekGridViewModel = new WeekGridViewModel(eventsRepository, currentUser); MonthGridViewModel = new MonthGridViewModel(eventsRepository, currentUser); addEventViewModel = new AddEventViewModel(eventsRepository, currentUser); CurrentViewModel = signInViewModel; ChangeCalendarModeCommand = new RelayCommand <CalendarMode>(OnChangeCalendarModeSelected); ShowAddEventCommand = new RelayCommand(OnShowAddEventSelected); RefreshCommand = new RelayCommand(OnRefreshSelected); EditEventsCommand = new RelayCommand(OnEditEventsSelected); }