public async Task <IHttpActionResult> PostSetItineraryParticipantsAsync(int itineraryId, int projectId, int itineraryStopId, [FromBody] ItineraryStopParticipantsBindingModel model) { if (ModelState.IsValid) { var user = this.userProvider.GetCurrentUser(); var businessUser = this.userProvider.GetBusinessUser(user); await this.itineraryStopService.SetParticipantsAsync(model.ToItineraryStopParticipants(businessUser, projectId, itineraryId, itineraryStopId)); await this.itineraryStopService.SaveChangesAsync(); return(Ok()); } else { return(BadRequest(ModelState)); } }
public void TestToItineraryStopParticipants() { var user = new User(1); var projectId = 1; var itineraryId = 2; var itineraryStopId = 3; var participantIds = new List <int> { 1, 2 }; var model = new ItineraryStopParticipantsBindingModel(); model.ParticipantIds = participantIds; var instance = model.ToItineraryStopParticipants(user, projectId, itineraryId, itineraryStopId); Assert.AreEqual(projectId, instance.ProjectId); Assert.AreEqual(itineraryId, instance.ItineraryId); Assert.AreEqual(itineraryStopId, instance.ItineraryStopId); CollectionAssert.AreEqual(instance.ParticipantIds.ToList(), participantIds.ToList()); }