Exemplo n.º 1
0
        public void Update(User user, string passwordHash, UserContactDto userContactDto, UserDataDto userDataDto,
                           UserPaymentDto userPaymentDto, UserNotificationOptionsDto userNotificationOptionsDto,
                           UserPermissionDto userPermissionDto, IList <UploadedFile> newDocuments, IList <Document> documentsToDelete,
                           EntityChangedDto entityChangedDto)
        {
            Require.NotNull(user, "user");
            Require.NotNull(userContactDto, "userContactDto");
            Require.NotNull(userDataDto, "userDataDto");
            Require.NotNull(userPermissionDto, "userPermissionDto");
            Require.NotNull(entityChangedDto, "entityChangedDto");
            Require.NotNull(documentsToDelete, "documentsToDelete");
            Require.NotNull(newDocuments, "newDocuments");

            IList <Document> documentsToAssign = newDocuments.Select(uf => DocumentRepository.Create(uf)).ToList();
            IList <Document> userDocuments     = user.Documents.Except(documentsToDelete).Concat(documentsToAssign).ToList();

            if (IsDirty(user,
                        passwordHash,
                        userContactDto,
                        userDataDto,
                        userPaymentDto,
                        userNotificationOptionsDto,
                        userPermissionDto,
                        userDocuments))
            {
                user.Update(passwordHash,
                            userContactDto,
                            userDataDto,
                            userPaymentDto,
                            userNotificationOptionsDto,
                            userPermissionDto,
                            userDocuments,
                            entityChangedDto);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Aktualisiert die Daten.
 /// </summary>
 /// <param name="userGroupDto">
 ///     <see cref="UserGroupDto" />
 /// </param>
 /// <param name="entityChangedDto">
 ///     <see cref="EntityChangedDto" />
 /// </param>
 public virtual void Update(UserGroupDto userGroupDto, EntityChangedDto entityChangedDto)
 {
     Require.NotNull(userGroupDto, nameof(userGroupDto));
     Require.NotNull(entityChangedDto, nameof(entityChangedDto));
     Update(userGroupDto);
     Update(entityChangedDto);
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Erstellt einen zufälligen Benutzer und gibt diesen zurück wenn keine Dtos übergeben werden
        /// </summary>
        /// <returns></returns>
        public User Create(string username, string passwordHash, UserDataDto userDataDto,
                           UserContactDto userContactDto, UserPaymentDto userPaymentDto, UserNotificationOptionsDto userNotifications,
                           UserPermissionDto userPermissionDto,
                           EntityCreatedDto entityCreatedDto, EntityChangedDto entityChangedDto, IList <Document> documents, bool persist = true)
        {
            User user = new User(passwordHash,
                                 userContactDto,
                                 userDataDto,
                                 userPaymentDto,
                                 userNotifications,
                                 userPermissionDto,
                                 documents,
                                 entityCreatedDto);

            if (entityChangedDto != null)
            {
                user.Update(userContactDto, userDataDto, userPaymentDto, userNotifications, entityChangedDto);
            }

            if (persist)
            {
                UserDao.Save(user);
                UserDao.Flush();
            }
            return(user);
        }
Exemplo n.º 4
0
        public void TestUpdate()
        {
            // given:
            UserGroup userGroupToUpdate = UserGroupCreator.Create();

            string           expectedAdditionalInformations = "Keine";
            string           expectedName            = "die firma";
            int              expectedAcceptedBalance = -20;
            UserGroupDto     userGroupDtoForUpdate   = new UserGroupDto(expectedAdditionalInformations, expectedName, expectedAcceptedBalance);
            User             changedBy        = UserCreator.Create("changed by");
            DateTime         changedAt        = new DateTime(2016, 12, 22);
            EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, changedAt);

            // when:
            userGroupToUpdate.Update(userGroupDtoForUpdate, entityChangedDto);
            UserGroupDao.FlushAndClear();
            UserGroup actualBrokerPool = UserGroupDao.Get(userGroupToUpdate.Id);

            // then:
            actualBrokerPool.GetDto().ShouldBeEquivalentTo(userGroupDtoForUpdate);
            actualBrokerPool.AdditionalInformations.ShouldBeEquivalentTo(expectedAdditionalInformations);
            actualBrokerPool.BalanceOverdraftLimit.ShouldBeEquivalentTo(expectedAcceptedBalance);
            actualBrokerPool.ChangedAt.Should().Be(changedAt);
            actualBrokerPool.ChangedBy.Should().Be(changedBy);
            actualBrokerPool.Name.ShouldBeEquivalentTo(expectedName);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Markiert den Peanut als fixiert.
        /// </summary>
        /// <param name="peanutState">Der neue Status, welchen der Peanut erhalten soll.</param>
        /// <param name="entityChangedDto"></param>
        public virtual void UpdateState(PeanutState peanutState, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");

            _peanutState = peanutState;
            Update(entityChangedDto);
        }
Exemplo n.º 6
0
        public void TestUpdateUserProfileProperties()
        {
            // given:
            User           user           = UserCreator.Create();
            User           userToUpdate   = UserDao.Get(user.Id);
            UserContactDto userContactDto = UserCreator.CreateUserContactDto("*****@*****.**",
                                                                             "Nürnberger Ei",
                                                                             "0",
                                                                             "01067",
                                                                             "Dresden",
                                                                             Country.DE,
                                                                             "Nürnberger Eieruhren GmbH",
                                                                             "http://www.nuernberger-eier.de",
                                                                             "phone",
                                                                             "privat",
                                                                             "mobile");
            UserDataDto                userDataDto      = UserCreator.CreateUserDataDto("neuerVorname", "neuerNachname", new DateTime(1990, 01, 03), "UserName");
            UserPaymentDto             userPaymentDto   = new UserPaymentDto("paypal", true);
            UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOn;
            User             changedBy        = UserCreator.Create();
            EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, new DateTime(2017, 01, 01, 01, 01, 01));

            // when:
            userToUpdate.Update(userContactDto, userDataDto, userPaymentDto, notificationsDto, entityChangedDto);
            UserDao.FlushAndClear();
            User actualUser = UserDao.Get(userToUpdate.Id);

            // then:
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());

            actualUser.ChangedBy.Should().Be(entityChangedDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(entityChangedDto.ChangedAt);
        }
Exemplo n.º 7
0
        public void ResetPassword(User user, string password, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");

            user.UpdatePassword(password, entityChangedDto);
            user.UpdatePasswordResetCode(Guid.Empty);
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Aktualisiert den Zeitpunkt und den durchführenden Nutzer der letzten Änderung an diesem Nutzer.
        /// </summary>
        /// <param name="entityChangedDto"></param>
        private void Update(EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");

            _changedBy = entityChangedDto.ChangedBy;
            _changedAt = entityChangedDto.ChangedAt;
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Entfernt alle übergebenen Dokumente aus der Liste mit Dokumenten, sofern sie in dieser enthalten sind.
        /// </summary>
        /// <param name="entityChanged"></param>
        /// <param name="documents"></param>
        public virtual void RemoveDocuments(EntityChangedDto entityChanged, params Document[] documents)
        {
            Require.NotNull(entityChanged, "entityChanged");
            Require.NotNull(documents, "documents");

            Update(entityChanged);
            _documents = _documents.Except(documents).ToList();
        }
Exemplo n.º 10
0
 public virtual void Update(string userName, ProposedUserDataDto proposedUserDataDto, ProposedUserContactDto proposedUserContactDto,
                            EntityChangedDto entityChangedDto)
 {
     _userName = userName;
     Update(proposedUserDataDto);
     Update(proposedUserContactDto);
     Update(entityChangedDto);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Markiert eine Rechnung als abgerechnet.
        /// </summary>
        /// <param name="entityChangedDto"></param>
        public virtual void Settle(EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");

            _isSettled      = true;
            _settlementDate = entityChangedDto.ChangedAt;

            Update(entityChangedDto);
        }
Exemplo n.º 12
0
        public virtual void Update(string comment, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");

            Update(comment);

            _changedBy = entityChangedDto.ChangedBy;
            _changedAt = entityChangedDto.ChangedAt;
        }
Exemplo n.º 13
0
        public void TestUpdateUserAllProperties()
        {
            // given:
            User           user           = UserCreator.Create();
            User           userToUpdate   = UserDao.Get(user.Id);
            UserContactDto userContactDto = UserCreator.CreateUserContactDto("*****@*****.**",
                                                                             "Nürnberger Ei",
                                                                             "0",
                                                                             "01067",
                                                                             "Dresden",
                                                                             Country.DE,
                                                                             "Nürnberger Eieruhren GmbH",
                                                                             "http://www.nuernberger-eier.de",
                                                                             "phone",
                                                                             "privat",
                                                                             "mobile");
            string            username          = "******";
            UserDataDto       userDataDto       = UserCreator.CreateUserDataDto("neuerVorname", "neuerNachname", null, username);
            User              changedBy         = UserCreator.Create();
            EntityChangedDto  entityChangedDto  = new EntityChangedDto(changedBy, new DateTime(2017, 01, 01, 01, 01, 01));
            UserPermissionDto userPermissionDto = new UserPermissionDto(new List <string> {
                Roles.Administrator
            }, true);
            UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOn;
            string          passwordHash = "newPasswordhash";
            List <Document> documents    = new List <Document> {
                DocumentCreator.Create()
            };
            UserPaymentDto userPaymentDto = new UserPaymentDto("", false);

            // when:
            userToUpdate.Update(passwordHash,
                                userContactDto,
                                userDataDto,
                                userPaymentDto,
                                notificationsDto,
                                userPermissionDto,
                                documents,
                                entityChangedDto);
            UserDao.FlushAndClear();
            User actualUser = UserDao.Get(userToUpdate.Id);

            // then:
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());
            DtoAssert.AreEqual(notificationsDto, actualUser.GetNotificationOptions());
            DtoAssert.AreEqual(userPermissionDto, actualUser.GetUserPermissionDto());

            actualUser.ChangedBy.Should().Be(entityChangedDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(entityChangedDto.ChangedAt);

            actualUser.UserName.Should().Be(username);
            actualUser.PasswordHash.Should().Be(passwordHash);

            actualUser.Documents.ShouldBeEquivalentTo(documents);
        }
Exemplo n.º 14
0
        public void Update(ProposedUser user, string username, ProposedUserDataDto proposedUserDataDto, ProposedUserContactDto proposedUserContactDto,
                           EntityChangedDto entityChangedDto)
        {
            Require.NotNull(user, "user");
            Require.NotNullOrWhiteSpace(username, "username");
            Require.NotNull(proposedUserDataDto, "proposedUserDataDto");
            Require.NotNull(proposedUserContactDto, "proposedUserContactDto");
            Require.NotNull(entityChangedDto, "entityChangedDto");

            user.Update(username, proposedUserDataDto, proposedUserContactDto, entityChangedDto);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Markiert die Zahlung als abgelehnt.
        /// </summary>
        /// <param name="declineReason">Warum wird die Zahlung abgelehnt?</param>
        /// <param name="entityChangedDto">Wann und von wem wurde die Zahlung abgelehnt.</param>
        public virtual void Decline(string declineReason, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(entityChangedDto, "entityChangedDto");
            Require.NotNullOrWhiteSpace(declineReason, "declineReason");

            _paymentStatus = PaymentStatus.Declined;
            _declineReason = declineReason;

            _declinedBy = entityChangedDto.ChangedBy;
            _declinedAt = entityChangedDto.ChangedAt;
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Erzeugt einen neuen Nutzer
        /// </summary>
        /// <returns></returns>
        public User Create(string username  = null, string email = "*****@*****.**", string lastname = NACHNAME_CONST,
                           string firstname = VORNAME_CONST, string passwordHash           = null,
                           string street    = STREET_CONST, string streetNumber            = STREET_NUMBER_CONST, string postalCode = POSTALCODE_CONST, string city = CITY_CONST,
                           Country countryTwoLetterIsoCode = COUNTRY_CONST, string company = COMPANY_CONST, string url              = URL_CONST,
                           string phone = null, string phonePrivate = null, string mobile = null, string fax = null,
                           string payPalBusinessName    = null, bool autoAcceptPayPalPayments    = true,
                           EntityCreatedDto creationDto = null, EntityChangedDto latestChangeDto = null,
                           IList <string> roles         = null, bool isEnabled = true, IList <Document> documents = null, DateTime?birthday = null, bool persist = true)
        {
            if (username == null)
            {
                username = GetRandomString(10);
            }
            if (firstname == VORNAME_CONST)
            {
                firstname = firstname + GetRandomString(4);
            }

            if (roles == null)
            {
                roles = new List <string> {
                    Roles.Member
                };
            }
            if (documents == null)
            {
                documents = new List <Document>();
            }

            UserContactDto userContactDto = CreateUserContactDto(email,
                                                                 street,
                                                                 streetNumber,
                                                                 postalCode,
                                                                 city,
                                                                 countryTwoLetterIsoCode,
                                                                 company,
                                                                 url,
                                                                 phone,
                                                                 phonePrivate,
                                                                 mobile);
            UserDataDto                userDataDto       = CreateUserDataDto(firstname, lastname, birthday, username);
            UserPermissionDto          userPermissionDto = CreateUserPermissionDto(roles, isEnabled);
            UserPaymentDto             userPaymentDto    = CreateUserPaymentDto(payPalBusinessName, autoAcceptPayPalPayments);
            UserNotificationOptionsDto userNotifications = UserNotificationOptionsDto.AllOn;

            if (creationDto == null)
            {
                creationDto = new EntityCreatedDto(null, DateTime.Now.Date);
            }

            User user = Create(username, passwordHash, userDataDto, userContactDto, userPaymentDto, userNotifications, userPermissionDto, creationDto, latestChangeDto, documents, persist);

            return(user);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Akzeptiert die Zahlung der Rechnung durch einen Debitor.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="entityChangedDto"></param>
        public virtual void AcceptByDebitor(User user, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(user, "user");
            Require.NotNull(entityChangedDto, "entityChangedDto");

            BillUserGroupDebitor debitor = _userGroupDebitors.SingleOrDefault(debMem => debMem.UserGroupMembership.User.Equals(user));

            if (debitor != null)
            {
                debitor.Accept();
                Update(entityChangedDto);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Fügt Teilnahmen an diesem Peanut hinzu.
        /// </summary>
        /// <param name="entityChanged"></param>
        /// <param name="participations"></param>
        public virtual void AddParticipators(EntityChangedDto entityChanged, params PeanutParticipation[] participations)
        {
            Require.NotNull(entityChanged, "entityChanged");
            Require.NotNull(participations, "participations");

            Update(entityChanged);
            foreach (PeanutParticipation participation in participations)
            {
                if (!_participations.Contains(participation))
                {
                    _participations.Add(participation);
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        ///     Entfernt Teilnahmen aus dem Peanut.
        /// </summary>
        /// <param name="entityChanged"></param>
        /// <param name="participatorsToDelete"></param>
        public virtual void RemoveParticipators(EntityChangedDto entityChanged, params UserGroupMembership[] participatorsToDelete)
        {
            Require.NotNull(entityChanged, "entityChanged");
            Require.NotNull(participatorsToDelete, "participatorsToDelete");

            Update(entityChanged);
            foreach (UserGroupMembership userGroupMembership in participatorsToDelete)
            {
                PeanutParticipation participationToDelete = _participations.SingleOrDefault(p => p.UserGroupMembership.Equals(userGroupMembership));
                if (participationToDelete != null)
                {
                    _participations.Remove(participationToDelete);
                }
            }
        }
Exemplo n.º 20
0
        public UserGroup Update(UserGroup userGroup, UserGroupDto userGroupDto, User changedBy)
        {
            Require.NotNull(userGroup, nameof(userGroup));
            Require.NotNull(userGroupDto, nameof(userGroupDto));
            Require.NotNull(changedBy, nameof(changedBy));

            if (userGroupDto.Equals(userGroup.GetDto()))
            {
                return(userGroup);
            }

            EntityChangedDto entityChangedDto = new EntityChangedDto(changedBy, DateTime.Now);

            userGroup.Update(userGroupDto, entityChangedDto);
            return(userGroup);
        }
Exemplo n.º 21
0
        public void Update(User user, string username, string passwordHash)
        {
            Require.NotNull(user, "user");
            Require.NotNullOrWhiteSpace(username, "username");
            Require.NotNullOrWhiteSpace(passwordHash, "passwordHash");

            if (IsDirty(user,
                        passwordHash,
                        user.GetUserContactDto(),
                        user.GetUserDataDto(),
                        user.GetUserPaymentDto(),
                        user.GetNotificationOptions(),
                        user.GetUserPermissionDto(),
                        user.Documents))
            {
                EntityChangedDto changedDto = new EntityChangedDto(user, DateTime.Now);
                user.UpdatePassword(passwordHash, changedDto);
            }
        }
Exemplo n.º 22
0
        public void Update(User user, UserContactDto userContactDto, UserDataDto userDataDto, UserPaymentDto userPaymentDto,
                           UserNotificationOptionsDto userNotificationOptionsDto, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(user, "user");
            Require.NotNull(userContactDto, "userContactDto");
            Require.NotNull(userDataDto, "userDataDto");
            Require.NotNull(entityChangedDto, "entityChangedDto");
            Require.NotNull(userPaymentDto, "userPaymentDto");

            if (IsDirty(user,
                        user.PasswordHash,
                        userContactDto,
                        userDataDto,
                        userPaymentDto,
                        userNotificationOptionsDto,
                        user.GetUserPermissionDto(),
                        user.Documents))
            {
                user.Update(userContactDto, userDataDto, userPaymentDto, userNotificationOptionsDto, entityChangedDto);
            }
        }
Exemplo n.º 23
0
        public void TestUpdateUserProfile()
        {
            // given:
            User                       userToUpdate     = UserCreator.Create();
            UserContactDto             userContactDto   = new UserContactDto("*****@*****.**", "Straße", "1", "01234", "Stadt", Country.DE, "Unternehmen", "http://www.test.url", "phone", "privat", "mobile");
            UserDataDto                userDataDto      = new UserDataDto("neuerVorname", "neuerNachname", new DateTime(1950, 05, 05), "UserName");
            UserPaymentDto             userPaymentDto   = new UserPaymentDto("PayPal", true);
            EntityChangedDto           changeDto        = new EntityChangedDto(UserCreator.Create(), new DateTime(2017, 01, 01, 01, 02, 03));
            UserNotificationOptionsDto notificationsDto = UserNotificationOptionsDto.AllOff;

            // when:
            UserService.Update(userToUpdate, userContactDto, userDataDto, userPaymentDto, notificationsDto, changeDto);
            UserService.UserDao.FlushAndClear();
            User actualUser = UserService.GetById(userToUpdate.Id);

            // then:
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());
            DtoAssert.AreEqual(notificationsDto, actualUser.GetNotificationOptions());

            actualUser.ChangedBy.Should().Be(changeDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(changeDto.ChangedAt);
        }
Exemplo n.º 24
0
        /// <summary>
        ///     Aktualisiert alle Eigenschaften des Nutzer und markiert ihn als geändert.
        /// </summary>
        /// <param name="passwordHash"></param>
        /// <param name="userContactDto"></param>
        /// <param name="userDataDto"></param>
        /// <param name="userPaymentDto"></param>
        /// <param name="userNotificationOptionsDto"></param>
        /// <param name="userPermissionDto"></param>
        /// <param name="documents">
        ///     Liste mit Dokumenten, die am Nutzer hinterlegt sein soll. Die Liste enthält sowohl neue, als
        ///     auch weiterhin hinterlegte Dokumente
        /// </param>
        /// <param name="entityChangedDto"></param>
        public virtual void Update(string passwordHash, UserContactDto userContactDto, UserDataDto userDataDto,
                                   UserPaymentDto userPaymentDto, UserNotificationOptionsDto userNotificationOptionsDto, UserPermissionDto userPermissionDto,
                                   IList <Document> documents, EntityChangedDto entityChangedDto)
        {
            Require.NotNullOrWhiteSpace(passwordHash, "passwordHash");
            Require.NotNull(userContactDto, "userContactDto");
            Require.NotNull(userDataDto, "userDataDto");
            Require.NotNull(userPermissionDto, "userPermissionDto");
            Require.NotNull(entityChangedDto, "entityChangedDto");
            Require.NotNull(documents, "documents");
            Require.NotNull(userPaymentDto, "userPaymentDto");
            Require.NotNull(userNotificationOptionsDto, "userNotificationOptionsDto");


            _passwordHash = passwordHash;

            Update(userContactDto);
            Update(userDataDto);
            Update(userPermissionDto);
            Update(documents);
            Update(userPaymentDto);
            Update(userNotificationOptionsDto);
            Update(entityChangedDto);
        }
Exemplo n.º 25
0
 private void Update(EntityChangedDto entityChanged)
 {
     _changedAt = entityChanged.ChangedAt;
     _changedBy = entityChanged.ChangedBy;
 }
Exemplo n.º 26
0
 /// <summary>
 ///     Markiert die Zahlung als akzeptiert.
 /// </summary>
 /// <param name="entityChangedDto"></param>
 public virtual void Accept(EntityChangedDto entityChangedDto)
 {
     _paymentStatus = PaymentStatus.Accecpted;
     _acceptedBy    = entityChangedDto.ChangedBy;
     _acceptedAt    = entityChangedDto.ChangedAt;
 }
Exemplo n.º 27
0
        /// <summary>
        ///     Aktualisiert das Passwort, bzw. den Hash des vom Nutzer verwendeten Passworts.
        /// </summary>
        /// <param name="passwordHash"></param>
        /// <param name="entityChangedDto">Wer hat das Passwort geändert und wann?</param>
        public virtual void UpdatePassword(string passwordHash, EntityChangedDto entityChangedDto)
        {
            _passwordHash = passwordHash;

            Update(entityChangedDto);
        }
Exemplo n.º 28
0
        /// <summary>
        ///     Aktualisiert die Profildaten des Nutzers und markiert ihn als geändert.
        /// </summary>
        /// <param name="userContactDto"></param>
        /// <param name="userDataDto"></param>
        /// <param name="userPaymentDto"></param>
        /// <param name="userNotificationOptionsDto"></param>
        /// <param name="entityChangedDto"></param>
        public virtual void Update(UserContactDto userContactDto, UserDataDto userDataDto, UserPaymentDto userPaymentDto,
                                   UserNotificationOptionsDto userNotificationOptionsDto, EntityChangedDto entityChangedDto)
        {
            Require.NotNull(userContactDto, "userContactDto");
            Require.NotNull(userDataDto, "userDataDto");
            Require.NotNull(entityChangedDto, "entityChangedDto");
            Require.NotNull(userPaymentDto, "userPaymentDto");
            Require.NotNull(userNotificationOptionsDto, "userNotificationOptionsDto");

            Update(userContactDto);
            Update(userDataDto);
            Update(userPaymentDto);
            Update(userNotificationOptionsDto);
            Update(entityChangedDto);
        }
Exemplo n.º 29
0
        public void TestUpdateUser()
        {
            // given:

            Service.UserService userService = new UserService();
            userService.UserDao = ContextRegistry.GetContext().GetObject <IUserDao>();

            Document document1    = DocumentCreator.Create();
            Document document2    = DocumentCreator.Create();
            Document document3    = DocumentCreator.Create();
            User     userToUpdate = UserCreator.Create(documents: new [] { document1, document2 });


            UploadedFile uploadedFile = new UploadedFile(new FileInfo("C:\\Temp\\passbild.png"));

            Mock <IDocumentRepository> fileServiceMock = new Mock <IDocumentRepository>();

            fileServiceMock.Setup(s => s.Create(uploadedFile)).Returns(document3);
            userService.DocumentRepository = fileServiceMock.Object;

            // when:
            // UserLoginDto userLoginDto = UserUtil.CreateUserLoginDto("neuernutzer", "anderesPasswort", false);
            UserContactDto userContactDto = new UserContactDto("*****@*****.**",
                                                               "Straße",
                                                               "1",
                                                               "01234",
                                                               "Stadt",
                                                               Country.DE,
                                                               "Unternehmen",
                                                               "http://www.test.url",
                                                               "phone",
                                                               "privat",
                                                               "mobile");
            const string      NEW_USERNAME      = "******";
            const string      NEW_PASSWORDHASH  = "andererPasswortHash";
            UserDataDto       userDataDto       = new UserDataDto("neuerVorname", "neuerNachname", new DateTime(2000, 02, 02), NEW_USERNAME);
            UserPaymentDto    userPaymentDto    = new UserPaymentDto("PayPal", true);
            UserPermissionDto userPermissionDto = UserCreator.CreateUserPermissionDto(new List <string>()
            {
                Roles.Administrator
            }, false);
            EntityChangedDto changeDto = new EntityChangedDto(UserCreator.Create(), new DateTime(2017, 01, 01, 01, 02, 03));

            UserNotificationOptionsDto userNotificationsDto = UserNotificationOptionsDto.AllOff;

            userService.Update(userToUpdate,
                               NEW_PASSWORDHASH,
                               userContactDto,
                               userDataDto,
                               userPaymentDto,
                               userNotificationsDto,
                               userPermissionDto,
                               new List <UploadedFile>()
            {
                uploadedFile
            },
                               new List <Document> {
                document2
            },
                               changeDto);
            userService.UserDao.FlushAndClear();

            User actualUser = UserService.GetById(userToUpdate.Id);

            // then:
            Assert.AreEqual(NEW_USERNAME, actualUser.UserName, "Der Nutzername wurde nicht korrekt übernommen.");
            Assert.AreEqual(NEW_PASSWORDHASH, actualUser.PasswordHash, "Das Passwort wurde nicht korrekt übernommen.");
            DtoAssert.AreEqual(userContactDto, actualUser.GetUserContactDto());
            DtoAssert.AreEqual(userDataDto, actualUser.GetUserDataDto());
            DtoAssert.AreEqual(userNotificationsDto, actualUser.GetNotificationOptions());
            DtoAssert.AreEqual(userPermissionDto, actualUser.GetUserPermissionDto());

            actualUser.Documents.Should().BeEquivalentTo(document1, document3);

            actualUser.ChangedBy.Should().Be(changeDto.ChangedBy);
            actualUser.ChangedAt.Should().Be(changeDto.ChangedAt);
        }
Exemplo n.º 30
0
 public virtual void Update(PeanutParticipationDto peanutParticipationDto, EntityChangedDto entityChangedDto)
 {
     Update(peanutParticipationDto);
     Update(entityChangedDto);
 }