public ValidationAppResult Add(Participant participant) { ValidationResult validationResult = _participantService.Add(participant); if (validationResult.IsValid) { Commit(); return(DomainToApplicationResult(validationResult)); } Rollback(); return(DomainToApplicationResult(validationResult)); }
public IHttpActionResult Post([FromBody] Participant participant) { // new participant try { var newParticipant = _service.Add(participant.EventId, participant.Person.Name, participant.Person.Email); return(Created(string.Format("api/participants/{0}", newParticipant.Id), Json(newParticipant).Content)); } catch (Exception ex) { HandleServerError(ex); return(InternalServerError()); } }
public ActionResult Create(ParticipantViewModel participant) { if (ModelState.IsValid) { try { var participantDomain = Mapper.Map <ParticipantViewModel, Participant>(participant); participantAppService.Add(participantDomain); return(RedirectToAction("List", new { id = participant.EventId })); } catch { return(View(participant)); } } return(View(participant)); }
public ActionResult Add(ParicipantModel paricipantModel) { if (!ModelState.IsValid) { return(Json(new { message = Localization.Localization.ErrorModelValidation, success = true })); } try { _participantService.Add(paricipantModel); } catch (ParticipantAlreadyRegisteredException) { return(Json(new { message = Localization.Localization.ErrorEventAlreadyEnrolledPlaceholder, success = false })); } catch (ParticipantCountReachedMaximumRoomCapacityException) { return(Json(new { message = Localization.Localization.ErrorEventParticipantReachedMaximumPlaceholder, success = false })); } return(Json(new { message = Localization.Localization.InfoParticipantAddedSuccess, success = true })); }