public void TestToAdditionalOrganizationProjectParticipant()
        {
            var model = new AdditionalOrganizationProjectPariticipantBindingModel();

            model.OrganizationId    = 1;
            model.ProjectId         = 2;
            model.ParticipantTypeId = ParticipantType.Individual.Id;
            var user           = new User(10);
            var businessEntity = model.ToAdditionalOrganizationProjectParticipant(user);

            Assert.AreEqual(model.OrganizationId, businessEntity.OrganizationId);
            Assert.AreEqual(model.ProjectId, businessEntity.ProjectId);
            Assert.AreEqual(model.ParticipantTypeId, businessEntity.ParticipantTypeId);
            Assert.IsTrue(Object.ReferenceEquals(user, businessEntity.Audit.User));
        }
예제 #2
0
        public async Task <IHttpActionResult> PostAddOrganizationParticipantAsync(AdditionalOrganizationProjectPariticipantBindingModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUser  = userProvider.GetCurrentUser();
                var businessUser = userProvider.GetBusinessUser(currentUser);
                await projectService.AddParticipantAsync(model.ToAdditionalOrganizationProjectParticipant(businessUser));

                await projectService.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }