Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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() }));
        }
Exemplo n.º 3
0
        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"));
        }