public void TestToAdditionalPersonProjectParticipant() { var model = new AdditionalPersonProjectParticipantBindingModel(); model.PersonId = 1; model.ProjectId = 2; model.ParticipantTypeId = ParticipantType.Individual.Id; var user = new User(10); var businessEntity = model.ToAdditionalPersonProjectParticipant(user); Assert.AreEqual(model.PersonId, businessEntity.PersonId); Assert.AreEqual(model.ProjectId, businessEntity.ProjectId); Assert.AreEqual(model.ParticipantTypeId, businessEntity.ParticipantTypeId); Assert.IsTrue(Object.ReferenceEquals(user, businessEntity.Audit.User)); }
public async Task <IHttpActionResult> PostAddPersonParticipantAsync(AdditionalPersonProjectParticipantBindingModel model) { if (ModelState.IsValid) { var currentUser = userProvider.GetCurrentUser(); var businessUser = userProvider.GetBusinessUser(currentUser); await projectService.AddParticipantAsync(model.ToAdditionalPersonProjectParticipant(businessUser)); await projectService.SaveChangesAsync(); return(Ok()); } else { return(BadRequest(ModelState)); } }