コード例 #1
0
        private async Task UpdatePrivlegesAsync(long personId,
                                                string plantId,
                                                PersonProjectHistory personProjectHistory,
                                                List <Project> parentProjects,
                                                List <long> updatedProjectIds)
        {
            await _privilegeService.GivePrivilegesAsync(plantId, personId);

            updatedProjectIds.ForEach(projectId =>
            {
                PersonProjectHistoryHelper.LogAddAccess(
                    personId,
                    personProjectHistory,
                    projectId,
                    _personCreatedByCache.Username);

                var isMainProject = parentProjects.Single(p => p.ProjectId == projectId).IsMainProject;

                if (isMainProject)
                {
                    PersonProjectHistoryHelper.LogDefaultUserGroup(
                        personId,
                        personProjectHistory,
                        projectId,
                        _personCreatedByCache.Username);
                }
            });
        }
コード例 #2
0
        public static PersonProjectHistory CreatePersonProjectHistory(long updatedById, string?updatedByUserName)
        {
            var personProjectHistory = new PersonProjectHistory
            {
                UpdatedAt         = DateTime.Now,
                UpdatedBy         = updatedById,
                UpdatedByUserName = updatedByUserName
            };

            return(personProjectHistory);
        }
コード例 #3
0
 public PersonProjectHistoryOperation(
     string operationType,
     long projectId,
     long personId,
     string?updatedByUser,
     PersonProjectHistory personProjectHistory)
 {
     OperationType        = operationType;
     ProjectId            = projectId;
     PersonId             = personId;
     UpdatedByUser        = updatedByUser;
     PersonProjectHistory = personProjectHistory;
 }
コード例 #4
0
        private static void LogInsert(
            long personId,
            PersonProjectHistory personProjectHistory,
            long projectId,
            string operationType,
            string?updatedByUsername)
        {
            var ppho = new PersonProjectHistoryOperation(
                operationType,
                projectId,
                personId,
                updatedByUsername,
                personProjectHistory);

            personProjectHistory.PersonProjectHistoryOperations.Add(ppho);
        }
        public void LogUnvoidProjects()
        {
            //Arrange
            var personProjectHistory = new PersonProjectHistory()
            {
                Id = 456
            };

            //Act
            PersonProjectHistoryHelper.LogUnvoidProjects(0004, personProjectHistory, 654, "PERSON_CREATED_BY");

            //Assert
            var personProjectHistoryOperation = personProjectHistory.PersonProjectHistoryOperations.FirstOrDefault();

            Assert.IsTrue(personProjectHistory.PersonProjectHistoryOperations.Count == 1);
            Assert.IsTrue(personProjectHistoryOperation.OperationType == "UPDATE");
            Assert.IsTrue(personProjectHistoryOperation.FieldName == "ISVOIDED");
            Assert.IsTrue(personProjectHistoryOperation.OldValue == "Y");
            Assert.IsTrue(personProjectHistoryOperation.NewValue == "N");
            Assert.IsTrue(personProjectHistoryOperation.UpdatedByUser == "PERSON_CREATED_BY");
        }
        public void LogDefaultUserGroup()
        {
            //Arrange
            var personProjectHistory = new PersonProjectHistory()
            {
                Id = 234
            };

            //Act
            PersonProjectHistoryHelper.LogDefaultUserGroup(0002, personProjectHistory, 432, "PERSON_CREATED_BY");

            //Assert
            var personProjectHistoryOperation = personProjectHistory.PersonProjectHistoryOperations.FirstOrDefault();

            Assert.IsTrue(personProjectHistory.PersonProjectHistoryOperations.Count == 1);
            Assert.IsTrue(personProjectHistoryOperation.OperationType == "User role");
            Assert.IsTrue(personProjectHistoryOperation.FieldName == "Read");
            Assert.IsTrue(personProjectHistoryOperation.NewValue == "Y");
            Assert.IsTrue(personProjectHistoryOperation.OldValue == "N");
            Assert.IsTrue(personProjectHistoryOperation.UpdatedByUser == "PERSON_CREATED_BY");
        }
        public void LogAddAccess()
        {
            //Arrange
            var personProjectHistory = new PersonProjectHistory()
            {
                Id = 123
            };

            //Act
            PersonProjectHistoryHelper.LogAddAccess(0001, personProjectHistory, 321, "PERSON_CREATED_BY");

            //Assert
            var personProjectHistoryOperation = personProjectHistory.PersonProjectHistoryOperations.FirstOrDefault();

            Assert.IsTrue(personProjectHistory.PersonProjectHistoryOperations.Count == 1);
            Assert.IsTrue(personProjectHistoryOperation.OperationType == "INSERT");
            Assert.IsTrue(personProjectHistoryOperation.FieldName == null);
            Assert.IsTrue(personProjectHistoryOperation.NewValue == null);
            Assert.IsTrue(personProjectHistoryOperation.OldValue == null);
            Assert.IsTrue(personProjectHistoryOperation.UpdatedByUser == "PERSON_CREATED_BY");
        }
コード例 #8
0
        private static void LogUpdate(
            long personId,
            PersonProjectHistory personProjectHistory,
            long projectId,
            string operationType,
            string fieldName,
            string oldValue,
            string newValue,
            string?updatedByUsername)
        {
            var ppho = new PersonProjectHistoryOperation(
                operationType,
                projectId,
                personId,
                updatedByUsername,
                personProjectHistory)
            {
                OldValue  = oldValue,
                NewValue  = newValue,
                FieldName = fieldName
            };

            personProjectHistory.PersonProjectHistoryOperations.Add(ppho);
        }
コード例 #9
0
 public static void LogVoidProjects(long personId, PersonProjectHistory personProjectHistory, long projectId, string?updatedByUsername)
 => LogUpdate(personId, personProjectHistory, projectId, "UPDATE", "ISVOIDED", "N", "Y", updatedByUsername);
コード例 #10
0
 public static void LogDefaultUserGroup(long personId, PersonProjectHistory personProjectHistory, long projectId, string?updatedByUsername)
 => LogUpdate(personId, personProjectHistory, projectId, "User role", "Read", "N", "Y", updatedByUsername);
コード例 #11
0
 public static void LogAddAccess(long personId, PersonProjectHistory personProjectHistory, long projectId, string?updatedByUsername)
 => LogInsert(personId, personProjectHistory, projectId, "INSERT", updatedByUsername);
 public async Task AddAsync(PersonProjectHistory personProjectHistory)
 {
     await _personProjectHistories.AddAsync(personProjectHistory);
 }