Esempio n. 1
0
        public void AddComment(Peanut peanut, string updateComment, PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(user, "user");
            Require.NotNull(notificationOptions, "notificationOptions");
            Require.NotNullOrWhiteSpace(updateComment, "updateComment");

            if (!string.IsNullOrWhiteSpace(updateComment))
            {
                /*Wenn es einen Änderungskommentar gibt, dann diesen hinzufügen.*/
                peanut.AddComment(updateComment, new EntityCreatedDto(user, DateTime.Now));
            }
            if (notificationOptions.SendNotification)
            {
                NotificationService.SendPeanutCommentNotification(peanut, updateComment, notificationOptions, user);
            }
        }
Esempio n. 2
0
        public void Update(Peanut peanut, PeanutDto peanutDto, IList <RequirementDto> requirements, string updateComment,
                           PeanutUpdateNotificationOptions notificationOptions, User user)
        {
            Require.NotNull(peanut, "peanut");
            Require.NotNull(peanutDto, "peanutDto");
            Require.NotNull(requirements, "requirements");
            Require.NotNull(user, "user");
            Require.NotNull(notificationOptions, "notificationOptions");

            PeanutDto dtoBeforeUpdate = peanut.GetDto();
            IList <PeanutRequirement> requirementsBeforeUpdate = peanut.Requirements;

            if (HasPeanutChanged(peanut, peanutDto, requirements))
            {
                /*Es wurden Änderungen am Peanut vorgenommen!*/
                peanut.Update(peanutDto, requirements, new EntityChangedDto(user, DateTime.Now));
                if (!string.IsNullOrWhiteSpace(updateComment))
                {
                    /*Wenn es einen Änderungskommentar gibt, dann diesen hinzufügen.*/
                    peanut.AddComment(updateComment, new EntityCreatedDto(user, DateTime.Now));
                }

                if (notificationOptions.SendNotification)
                {
                    NotificationService.SendPeanutUpdateNotification(peanut,
                                                                     dtoBeforeUpdate,
                                                                     requirementsBeforeUpdate,
                                                                     updateComment,
                                                                     notificationOptions,
                                                                     user);
                }
                if (HaveRequirementsChanged(requirementsBeforeUpdate, requirements))
                {
                    NotificationService.SendPeanutUpdateRequirementsNotification(peanut,
                                                                                 updateComment,
                                                                                 new PeanutUpdateRequirementsNotificationOptions(notificationOptions.PeanutUrl),
                                                                                 user);
                }
            }
            else if (!string.IsNullOrWhiteSpace(updateComment))
            {
                /*Es wurde nur ein Kommentar hinterlassen*/
                AddComment(peanut, updateComment, notificationOptions, user);
            }
        }