public void Create(EulaModel viewModel, EducationSecurityPrincipal user)
 {
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     if (!user.IsInRole(SecurityRoles.DataAdmin))
     {
         throw new EntityAccessUnauthorizedException("user");
     }
     EulaAgreement agreement = new EulaAgreement
     {
         CreateTime = DateTime.Now,
         CreatingUser = user.Identity.User
     };
     viewModel.CopyTo(agreement);
     EulaAgreementRepository.Add(agreement);
     EulaAcceptance acceptance = new EulaAcceptance
     {
         EulaAgreement = agreement,
         CreatingUserId = user.Identity.User.Id,
         CreateTime = DateTime.Now
     };
     if (user.Identity.User.EulaAcceptances == null)
     {
         user.Identity.User.EulaAcceptances = new List<EulaAcceptance>();
     }
     user.Identity.User.EulaAcceptances.Add(acceptance);
     UserRepository.Update(user.Identity.User);
     RepositoryContainer.Save();
 }
        public void GivenAnEulaAcceptance_WhenAdd_ThenAddToContext()
        {
            var expected = new EulaAcceptance { Id = 1, EulaAgreement = new EulaAgreement() };

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
        public void GivenAnEulaAcceptance_WhenUpdate_ThenThrowException()
        {
            var acceptance = new EulaAcceptance { Id = 1, EulaAgreement = new EulaAgreement() };

            Target.ExpectException<NotSupportedException>(() => Target.Update(acceptance));
        }
 public void Log(EulaModel viewModel, EducationSecurityPrincipal user)
 {
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     EulaAcceptance acceptance = new EulaAcceptance
     {
         EulaAgreementId = viewModel.Id,
         CreatingUserId = user.Identity.User.Id,
         CreateTime = DateTime.Now
     };
     user.Identity.User.EulaAcceptances.Add(acceptance);
     UserRepository.Update(user.Identity.User);
     RepositoryContainer.Save();
 }
 public void Update(EulaAcceptance item)
 {
     throw new NotSupportedException("Update is not supported in this repository");
 }
 public void Add(EulaAcceptance item)
 {
     Context.EulaAcceptances.Add(item);
 }