public int Post(EventDefinition eventDefinition) { if (eventDefinition == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } var token = MyEventsToken.GetTokenFromHeader(); if (token.RegisteredUserId != eventDefinition.OrganizerId) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } return(_eventDefinitionRepository.Add(eventDefinition)); }
public ActionResult Create(MyEventsIdentity identity, EditEventViewModel viewModel) { SetLogo(viewModel, ModelState); if (!ModelState.IsValid) { return(View(viewModel)); } var eventDefinition = new EventDefinition(); MapViewModelToEventDefinition(viewModel, eventDefinition); eventDefinition.OrganizerId = identity.UserId; _eventsRepository.Add(eventDefinition); ResetLogo(); return(RedirectToAction("Index", "Home")); }