public async Task<IActionResult> Create(int eventId) { var campaignEvent = await _mediator.SendAsync(new EventSummaryQuery { EventId = eventId }); if (campaignEvent == null) { return BadRequest("Invalid event id"); } if (!User.IsOrganizationAdmin(campaignEvent.OrganizationId)) { return Unauthorized(); } var model = new EditRequestViewModel { OrganizationId = campaignEvent.OrganizationId, OrganizationName = campaignEvent.OrganizationName, CampaignId = campaignEvent.CampaignId, CampaignName = campaignEvent.CampaignName, EventId = campaignEvent.Id, EventName = campaignEvent.Name, }; ViewBag.Title = CreateRequestTitle; return View("Edit", model); }
public async Task<IActionResult> Edit(EditRequestViewModel model) { var campaignEvent = await _mediator.SendAsync(new EventSummaryQuery { EventId = model.EventId }); if (campaignEvent == null) { return BadRequest("Invalid event id"); } if (!User.IsOrganizationAdmin(campaignEvent.OrganizationId)) { return Unauthorized(); } if (!ModelState.IsValid) { return View("Edit", model); } await _mediator.SendAsync(new EditRequestCommand { RequestModel = model }); return RedirectToAction("Requests", "Event", new { id = model.EventId }); }