public async Task <ActionResult <EventDto> > Put(int id, [FromBody] EventFormDto dto) { var eventInfo = await _eventInfoService.GetEventInfoByIdAsync(id); if (eventInfo.Archived) { return(NotFound()); } dto.CopyTo(eventInfo); await _eventManagementService.UpdateEventAsync(eventInfo); return(Ok(new EventDto(eventInfo))); }
public async Task <ActionResult> Index(EventModel model) { if (!ModelState.IsValid) { return(View(model)); } var eventEntity = Mapper.Map <Event>(model); eventEntity = (model.Id.HasValue) ? await _eventManagementService.UpdateEventAsync(eventEntity) : await _eventManagementService.CreateEventAsync(eventEntity, User.Identity.GetUserId()); return(RedirectToAction("Index", "Share", new { eventHash = eventEntity.Id.GetUniqueUrlParameter() })); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(await PageAsync()); } if (!User.IsInRole(Roles.SuperAdmin)) { // Force current org id to be set by all admins except // super admin who can choose not to bind event to the org. EventInfo.OrganizationId = (await _currentOrganizationAccessorService .RequireCurrentOrganizationAsync()) .OrganizationId; } await _eventsService.UpdateEventAsync(EventInfo); return(RedirectToPage("./Index")); }