コード例 #1
0
ファイル: EventsController.cs プロジェクト: losol/eventuras
        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)));
        }
コード例 #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() }));
        }
コード例 #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"));
        }