protected override TemplateCollaboration BeforeCreate(TemplateCollaboration entity)
        {
            if (entity.TemplateCollaborationUsers != null && entity.TemplateCollaborationUsers.Count > 0)
            {
                foreach (TemplateCollaborationUser item in entity.TemplateCollaborationUsers)
                {
                    if (item.Role != null)
                    {
                        item.Role = _unitOfWork.Repository <Role>().Find(item.Role.EntityShortId);
                    }
                }
                _unitOfWork.Repository <TemplateCollaborationUser>().InsertRange(entity.TemplateCollaborationUsers);
            }

            if (entity.TemplateCollaborationDocumentRepositories != null && entity.TemplateCollaborationDocumentRepositories.Count > 0)
            {
                foreach (TemplateCollaborationDocumentRepository item in entity.TemplateCollaborationDocumentRepositories)
                {
                    //TODO: Gestire entità templatedocumentrepositories
                }
                _unitOfWork.Repository <TemplateCollaborationDocumentRepository>().InsertRange(entity.TemplateCollaborationDocumentRepositories);
            }

            if (entity.Roles != null && entity.Roles.Count > 0)
            {
                entity.Roles = entity.Roles.Select(r => _unitOfWork.Repository <Role>().Find(r.EntityShortId)).ToList();
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, string.Concat("Inserimento template collaborazione", entity.Name), typeof(TemplateCollaboration).Name, CurrentDomainUser.Account));
            return(base.BeforeCreate(entity));
        }
        protected override ResolutionKind BeforeDelete(ResolutionKind entity, ResolutionKind entityTransformed)
        {
            if (entityTransformed.ResolutionKindDocumentSeries != null)
            {
                _unitOfWork.Repository <ResolutionKindDocumentSeries>().DeleteRange(entityTransformed.ResolutionKindDocumentSeries.ToList());
            }
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Eliminata tipologia atto ", entity.Name), typeof(ResolutionKind).Name, CurrentDomainUser.Account));

            return(base.BeforeDelete(entity, entityTransformed));
        }
Exemple #3
0
        protected override TenantConfiguration BeforeUpdate(TenantConfiguration entity, TenantConfiguration entityTransformed)
        {
            if (entity.Tenant != null)
            {
                entityTransformed.Tenant = _unitOfWork.Repository <Tenant>().Find(entity.Tenant.UniqueId);
            }
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, string.Concat("Aggiornamento configurazione azienda ", entity.Tenant != null ? entity.Tenant.TenantName : ""), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));

            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override ProcessFascicleTemplate BeforeUpdate(ProcessFascicleTemplate entity, ProcessFascicleTemplate entityTransformed)
        {
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, $"Modificata tipologia atto {entity.Name} con ID {entity.UniqueId}", typeof(ProcessFascicleTemplate).Name, CurrentDomainUser.Account));

            if (entity.Process != null)
            {
                entityTransformed.Process = _unitOfWork.Repository <Process>().Find(entity.Process.UniqueId);
            }
            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override Process BeforeDelete(Process entity, Process entityTransformed)
        {
            if (CurrentDeleteActionType != null && CurrentDeleteActionType != Common.Infrastructures.DeleteActionType.CancelProcess)
            {
                throw new DSWException(EXCEPTION_MESSAGE, null, DSWExceptionCode.SS_NotAllowedOperation);
            }
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, $"Rimosso raccolta dei procedimenti {entity.Name}", typeof(Process).Name, CurrentDomainUser.Account));

            return(base.BeforeDelete(entity, entityTransformed));
        }
        protected override ProcessFascicleWorkflowRepository BeforeUpdate(ProcessFascicleWorkflowRepository entity, ProcessFascicleWorkflowRepository entityTransformed)
        {
            if (entity.WorkflowRepository != null)
            {
                entityTransformed.WorkflowRepository = _unitOfWork.Repository <WorkflowRepository>().Find(entity.WorkflowRepository.UniqueId);
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, $"Modificata di entità '{typeof(ProcessFascicleWorkflowRepository).Name}' con ID {entity.UniqueId}", typeof(ProcessFascicleWorkflowRepository).Name, CurrentDomainUser.Account));

            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override Process BeforeCreate(Process entity)
        {
            entity.StartDate   = DateTimeOffset.UtcNow;
            entity.ProcessType = ProcessType.Created;
            if (entity.Category != null)
            {
                entity.Category = _unitOfWork.Repository <Category>().Find(entity.Category.EntityShortId);
            }

            if (entity.Roles != null)
            {
                HashSet <Role> roles = new HashSet <Role>();
                Role           role  = null;
                foreach (Role item in entity.Roles)
                {
                    role = _unitOfWork.Repository <Role>().Find(item.EntityShortId);
                    if (role != null)
                    {
                        roles.Add(role);
                    }
                }
                entity.Roles = roles;
            }

            Dossier defaultDossier = new Dossier()
            {
                Subject     = entity.Name,
                Note        = entity.Note,
                StartDate   = DateTimeOffset.UtcNow,
                DossierType = DossierType.Process,
                Status      = DossierStatus.Open
            };

            defaultDossier.Container = _unitOfWork.Repository <Container>().Find(_parameterEnvService.ProcessContainerId);
            defaultDossier.DossierRoles.Add(new DossierRole()
            {
                AuthorizationRoleType = AuthorizationRoleType.Responsible,
                Role = _unitOfWork.Repository <Role>().Find(_parameterEnvService.ProcessRoleId)
            });
            defaultDossier.Category = entity.Category;
            defaultDossier          = Task.Run <Dossier>(async() =>
            {
                return(await _dossierService.CreateAsync(defaultDossier));
            }).Result;

            entity.Dossier = defaultDossier;
            _logger.WriteDebug(new LogMessage($"Generated automatically new dossier {defaultDossier.Subject}({defaultDossier.UniqueId}) to process {entity.Name} ({entity.UniqueId})"), LogCategories);

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, $"Inserita raccolta dei procedimenti {entity.Name}", typeof(Process).Name, CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
        protected override TemplateCollaboration BeforeUpdate(TemplateCollaboration entity, TemplateCollaboration entityTransformed)
        {
            if (entity.TemplateCollaborationUsers != null)
            {
                foreach (TemplateCollaborationUser item in entity.TemplateCollaborationUsers.Where(f => entityTransformed.TemplateCollaborationUsers.Any(c => c.UniqueId == f.UniqueId)))
                {
                    TemplateCollaborationUser mappedUser = _mapperUnitOfWork.Repository <TemplateCollaborationUserMapper>().Map(item, entityTransformed.TemplateCollaborationUsers.First(c => c.UniqueId == item.UniqueId));
                    _unitOfWork.Repository <TemplateCollaborationUser>().Update(mappedUser);
                }
                foreach (TemplateCollaborationUser item in entityTransformed.TemplateCollaborationUsers.Where(f => !entity.TemplateCollaborationUsers.Any(c => c.UniqueId == f.UniqueId)).ToList())
                {
                    _unitOfWork.Repository <TemplateCollaborationUser>().Delete(item.UniqueId);
                }
                foreach (TemplateCollaborationUser item in entity.TemplateCollaborationUsers.Where(f => !entityTransformed.TemplateCollaborationUsers.Any(c => c.UniqueId == f.UniqueId)))
                {
                    item.TemplateCollaboration = entityTransformed;
                    if (item.Role != null)
                    {
                        item.Role = _unitOfWork.Repository <Role>().Find(item.Role.EntityShortId);
                    }
                    _unitOfWork.Repository <TemplateCollaborationUser>().Insert(item);
                }
            }

            if (entity.TemplateCollaborationDocumentRepositories != null)
            {
                foreach (TemplateCollaborationDocumentRepository item in entityTransformed.TemplateCollaborationDocumentRepositories.Where(f => !entity.TemplateCollaborationDocumentRepositories.Any(c => c.UniqueId == f.UniqueId)).ToList())
                {
                    entityTransformed.TemplateCollaborationDocumentRepositories.Remove(item);
                }
                foreach (TemplateCollaborationDocumentRepository item in entity.TemplateCollaborationDocumentRepositories.Where(f => !entityTransformed.TemplateCollaborationDocumentRepositories.Any(c => c.UniqueId == f.UniqueId)))
                {
                    item.TemplateCollaboration = entityTransformed;
                    //TODO: Gestire entità templatedocumentrepositories
                    _unitOfWork.Repository <TemplateCollaborationDocumentRepository>().Insert(item);
                }
            }

            if (entity.Roles != null)
            {
                foreach (Role item in entityTransformed.Roles.Where(f => !entity.Roles.Any(c => c.EntityShortId == f.EntityShortId)).ToList())
                {
                    entityTransformed.Roles.Remove(item);
                }
                foreach (Role item in entity.Roles.Where(f => !entityTransformed.Roles.Any(c => c.EntityShortId == f.EntityShortId)))
                {
                    entityTransformed.Roles.Add(_unitOfWork.Repository <Role>().Find(item.EntityShortId));
                }
            }
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, string.Concat("Modificato template collaborazione", entity.Name), typeof(TemplateCollaboration).Name, CurrentDomainUser.Account));
            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override ProcessFascicleWorkflowRepository BeforeCreate(ProcessFascicleWorkflowRepository entity)
        {
            if (entity.DossierFolder != null)
            {
                entity.DossierFolder = _unitOfWork.Repository <DossierFolder>().Find(entity.DossierFolder.UniqueId);
            }

            if (entity.Process != null)
            {
                entity.Process = _unitOfWork.Repository <Process>().Find(entity.Process.UniqueId);
            }

            if (entity.WorkflowRepository != null)
            {
                entity.WorkflowRepository = _unitOfWork.Repository <WorkflowRepository>().Find(entity.WorkflowRepository.UniqueId);
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, $"Inserimento di entità '{typeof(ProcessFascicleWorkflowRepository).Name}' con ID {entity.UniqueId}", typeof(ProcessFascicleWorkflowRepository).Name, CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
        protected override TemplateCollaboration BeforeDelete(TemplateCollaboration entity, TemplateCollaboration entityTransformed)
        {
            if (entityTransformed.TemplateCollaborationUsers != null)
            {
                _unitOfWork.Repository <TemplateCollaborationUser>().DeleteRange(entityTransformed.TemplateCollaborationUsers.ToList());
            }

            if (entityTransformed.TemplateCollaborationDocumentRepositories != null)
            {
                _unitOfWork.Repository <TemplateCollaborationDocumentRepository>().DeleteRange(entityTransformed.TemplateCollaborationDocumentRepositories.ToList());
            }

            if (entityTransformed.Roles != null)
            {
                entityTransformed.Roles.Clear();
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Eliminato template collaborazione", entity.Name), typeof(TemplateCollaboration).Name, CurrentDomainUser.Account));

            return(base.BeforeDelete(entity, entityTransformed));
        }
        protected override TenantAOO BeforeCreate(TenantAOO entity)
        {
            if (entity.TenantTypology == TenantTypologyType.InternalTenant)
            {
                Parameter parameter = CreateTenantAOOParameter(entity);
                _unitOfWork.Repository <Parameter>().Insert(parameter);

                Category defaultCategory = new Category
                {
                    Name      = entity.Name,
                    Code      = 0,
                    StartDate = DateTimeOffset.UtcNow.Date,
                    IsActive  = ActiveType.Active
                };

                defaultCategory.CategorySchema = _unitOfWork.Repository <CategorySchema>().FindActiveCategorySchema();
                _unitOfWork.Repository <Category>().Insert(defaultCategory);
                entity.Categories.Add(defaultCategory);
                _logger.WriteDebug(new LogMessage($"Generated automatically new category {defaultCategory.Name}({defaultCategory.UniqueId}) to tenantaoo {entity.Name} ({entity.UniqueId})"), LogCategories);
                _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, $"Inserita nuova AOO {entity.Name}", typeof(TenantAOO).Name, CurrentDomainUser.Account));
            }
            return(base.BeforeCreate(entity));
        }
        protected override ProcessFascicleTemplate BeforeCreate(ProcessFascicleTemplate entity)
        {
            entity.StartDate = DateTimeOffset.UtcNow;
            entity.EndDate   = null;
            if (entity.DossierFolder != null)
            {
                entity.DossierFolder = _unitOfWork.Repository <DossierFolder>().Find(entity.DossierFolder.UniqueId);
            }

            if (entity.DossierFolder != null)
            {
                entity.DossierFolder.Status = DossierFolderStatus.Folder;
                _unitOfWork.Repository <DossierFolder>().Update(entity.DossierFolder);
            }

            if (entity.Process != null)
            {
                entity.Process = _unitOfWork.Repository <Process>().Find(entity.Process.UniqueId);
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, $"Inserimento tipologia atto {entity.Name}", typeof(ProcessFascicleTemplate).Name, CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
Exemple #13
0
        protected override Process BeforeUpdate(Process entity, Process entityTransformed)
        {
            entityTransformed.ProcessType = ProcessType.Defined;
            if (entity.Category != null)
            {
                entityTransformed.Category = _unitOfWork.Repository <Category>().Find(entity.Category.EntityShortId);
            }

            if (entity.Roles != null)
            {
                foreach (Role item in entityTransformed.Roles.Where(f => !entity.Roles.Any(c => c.EntityShortId == f.EntityShortId)).ToList())
                {
                    foreach (DossierFolder df in entityTransformed.Dossier.DossierFolders)
                    {
                        if (df.DossierFolderRoles.Count() != 0)
                        {
                            DossierFolderRole role = df.DossierFolderRoles.FirstOrDefault(x => x.Role.EntityShortId == item.EntityShortId);
                            if (role != null)
                            {
                                _unitOfWork.Repository <DossierFolderRole>().Delete(role);
                                _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il settore '", item.Name, "' da volumi '", df.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                            }
                        }

                        if (df.FascicleTemplates.Count() != 0)
                        {
                            foreach (ProcessFascicleTemplate pft in df.FascicleTemplates)
                            {
                                if (pft.JsonModel != null && !String.IsNullOrEmpty(pft.JsonModel))
                                {
                                    Fascicle     fascicle = JsonConvert.DeserializeObject <Fascicle>(pft.JsonModel);
                                    FascicleRole role     = fascicle.FascicleRoles.FirstOrDefault(x => x.Role.EntityShortId == item.EntityShortId);
                                    if (role != null && role.IsMaster)
                                    {
                                        fascicle.FascicleRoles.Remove(role);
                                        pft.JsonModel = JsonConvert.SerializeObject(fascicle);
                                        _unitOfWork.Repository <ProcessFascicleTemplate>().Update(pft);
                                        _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il settore '", item.Name, "' da modello di fascicolo '", pft.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                                    }
                                }
                            }
                        }
                    }

                    entityTransformed.Roles.Remove(item);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il settore '", item.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                }
                foreach (Role item in entity.Roles.Where(f => !entityTransformed.Roles.Any(c => c.EntityShortId == f.EntityShortId)))
                {
                    foreach (DossierFolder df in entityTransformed.Dossier.DossierFolders)
                    {
                        DossierFolderRole role = new DossierFolderRole
                        {
                            Role = _unitOfWork.Repository <Role>().Find(item.EntityShortId),
                            AuthorizationRoleType = AuthorizationRoleType.Accounted,
                            IsMaster      = true,
                            DossierFolder = _unitOfWork.Repository <DossierFolder>().Find(df.UniqueId),
                            Status        = DossierRoleStatus.Active
                        };

                        if (!df.DossierFolderRoles.Any(x => x.Role.EntityId == item.EntityShortId))
                        {
                            _unitOfWork.Repository <DossierFolderRole>().Insert(role);
                            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il settore '", item.Name, "' da volumi '", df.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                        }
                    }
                    entityTransformed.Roles.Add(_unitOfWork.Repository <Role>().Find(item.EntityShortId));
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il settore '", item.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                }
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, $"Modificata raccolta dei procedimenti {entity.Name} con ID {entity.UniqueId}", typeof(Process).Name, CurrentDomainUser.Account));

            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override ResolutionKind BeforeCreate(ResolutionKind entity)
        {
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, string.Concat("Inserimento tipologia atto ", entity.Name), typeof(ResolutionKind).Name, CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
        protected override ResolutionKind BeforeUpdate(ResolutionKind entity, ResolutionKind entityTransformed)
        {
            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, string.Concat("Modificata tipologia atto ", entity.Name, " con ID ", entity.UniqueId), typeof(ResolutionKind).Name, CurrentDomainUser.Account));

            return(base.BeforeUpdate(entity, entityTransformed));
        }
Exemple #16
0
        protected override Tenant BeforeCreate(Tenant entity)
        {
            if (entity.TenantAOO != null)
            {
                entity.TenantAOO = _unitOfWork.Repository <TenantAOO>().Find(entity.TenantAOO.UniqueId);
            }

            if (entity.Configurations != null && entity.Configurations.Count > 0)
            {
                foreach (TenantConfiguration item in entity.Configurations)
                {
                    item.Tenant = entity;
                }
            }

            if (entity.Containers != null)
            {
                HashSet <Container> containers = new HashSet <Container>();
                Container           container  = null;
                foreach (Container item in entity.Containers)
                {
                    container = _unitOfWork.Repository <Container>().Find(item.EntityShortId);
                    if (container != null)
                    {
                        containers.Add(container);
                    }
                }
                entity.Containers = containers;
            }

            if (entity.Roles != null)
            {
                HashSet <Role> roles = new HashSet <Role>();
                Role           role  = null;
                foreach (Role item in entity.Roles)
                {
                    role = _unitOfWork.Repository <Role>().Find(item.EntityShortId);
                    if (role != null)
                    {
                        roles.Add(role);
                    }
                }
                entity.Roles = roles;
            }

            if (entity.PECMailBoxes != null)
            {
                HashSet <PECMailBox> pecMailBoxes = new HashSet <PECMailBox>();
                PECMailBox           pecMailBox   = null;
                foreach (PECMailBox item in entity.PECMailBoxes)
                {
                    pecMailBox = _unitOfWork.Repository <PECMailBox>().Find(item.EntityShortId);
                    if (pecMailBox != null)
                    {
                        pecMailBoxes.Add(pecMailBox);
                    }
                }
                entity.PECMailBoxes = pecMailBoxes;
            }

            if (entity.TenantWorkflowRepositories != null)
            {
                HashSet <TenantWorkflowRepository> tenantWorkflowRepositories = new HashSet <TenantWorkflowRepository>();
                TenantWorkflowRepository           tenantWorkflowRepository   = null;
                foreach (TenantWorkflowRepository item in entity.TenantWorkflowRepositories)
                {
                    tenantWorkflowRepository = _unitOfWork.Repository <TenantWorkflowRepository>().Find(item.UniqueId);
                    if (tenantWorkflowRepository != null)
                    {
                        tenantWorkflowRepositories.Add(tenantWorkflowRepository);
                    }
                }
                entity.TenantWorkflowRepositories = tenantWorkflowRepositories;
            }

            if (entity.Contacts != null)
            {
                HashSet <Contact> tenantContacts = new HashSet <Contact>();
                Contact           tenantContact  = null;
                foreach (Contact item in entity.Contacts)
                {
                    tenantContact = _unitOfWork.Repository <Contact>().Find(item.EntityId);
                    if (tenantContact != null)
                    {
                        tenantContacts.Add(tenantContact);
                    }
                }
                entity.Contacts = tenantContacts;
            }

            _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, string.Concat("Inserimento OU ", entity.TenantName), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
Exemple #17
0
        protected override Tenant BeforeUpdate(Tenant entity, Tenant entityTransformed)
        {
            if (CurrentUpdateActionType.HasValue)
            {
                switch (CurrentUpdateActionType.Value)
                {
                case UpdateActionType.TenantConfigurationAdd:
                {
                    TenantConfiguration configuration = entity.Configurations.FirstOrDefault();
                    configuration.Tenant = entityTransformed;
                    _unitOfWork.Repository <TenantConfiguration>().Insert(configuration);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunta la configurazione '", configuration.Tenant != null ? configuration.Tenant.TenantName : "", "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantConfigurationRemove:
                {
                    TenantConfiguration configuration = entityTransformed.Configurations.FirstOrDefault(x => x.UniqueId == entity.Configurations.FirstOrDefault().UniqueId);
                    _unitOfWork.Repository <TenantConfiguration>().Delete(configuration);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimossa la configurazione '", configuration.Tenant != null ? configuration.Tenant.TenantName : "", "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantContactAdd:
                {
                    Contact contact = entity.Contacts.FirstOrDefault();
                    entityTransformed.Contacts.Add(_unitOfWork.Repository <Contact>().Find(contact.EntityId));
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il contatto '", contact.Description, "'"), typeof(Contact).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantContactRemove:
                {
                    Contact contact = entityTransformed.Contacts.FirstOrDefault(x => x.EntityId == entity.Contacts.FirstOrDefault().EntityId);
                    entityTransformed.Contacts.Remove(contact);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il contatto '", contact.Description, "'"), typeof(Contact).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantContainerAdd:
                {
                    Container container = entity.Containers.FirstOrDefault();
                    entityTransformed.Containers.Add(_unitOfWork.Repository <Container>().Find(container.EntityShortId));
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il contenitore '", container.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantContainerRemove:
                {
                    Container container = entityTransformed.Containers.FirstOrDefault(x => x.EntityShortId == entity.Containers.FirstOrDefault().EntityShortId);
                    entityTransformed.Containers.Remove(container);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il contenitore '", container.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantRoleAdd:
                {
                    foreach (Role role in entity.Roles)
                    {
                        entityTransformed.Roles.Add(_unitOfWork.Repository <Role>().Find(role.EntityShortId));
                        _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il settore '", role.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    }
                    break;
                }

                case UpdateActionType.TenantRoleRemove:
                {
                    Role role = entityTransformed.Roles.FirstOrDefault(x => x.EntityShortId == entity.Roles.FirstOrDefault().EntityShortId);
                    entityTransformed.Roles.Remove(role);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il settore '", role.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantPECMailBoxAdd:
                {
                    PECMailBox pecMailBox = entity.PECMailBoxes.FirstOrDefault();
                    entityTransformed.PECMailBoxes.Add(_unitOfWork.Repository <PECMailBox>().Find(pecMailBox.EntityShortId));
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto la casella PEC '", pecMailBox.MailBoxRecipient, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantPECMailBoxRemove:
                {
                    PECMailBox pecMailBox = entityTransformed.PECMailBoxes.FirstOrDefault(x => x.EntityShortId == entity.PECMailBoxes.FirstOrDefault().EntityShortId);
                    entityTransformed.PECMailBoxes.Remove(pecMailBox);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso la casella PEC '", pecMailBox.MailBoxRecipient, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantWorkflowRepositoryAdd:
                {
                    TenantWorkflowRepository tenantWorkflowRepository = entity.TenantWorkflowRepositories.FirstOrDefault();
                    entityTransformed.TenantWorkflowRepositories.Add(_unitOfWork.Repository <TenantWorkflowRepository>().Find(tenantWorkflowRepository.UniqueId));
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.INSERT, string.Concat("Aggiunto il flusso di lavoro '", tenantWorkflowRepository.WorkflowRepository.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantWorkflowRepositoryRemove:
                {
                    TenantWorkflowRepository tenantWorkflowRepository = entityTransformed.TenantWorkflowRepositories.FirstOrDefault(x => x.UniqueId == entity.TenantWorkflowRepositories.FirstOrDefault().UniqueId);
                    entityTransformed.TenantWorkflowRepositories.Remove(tenantWorkflowRepository);
                    _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.DELETE, string.Concat("Rimosso il flusso di lavoro '", tenantWorkflowRepository.WorkflowRepository.Name, "'"), typeof(TenantConfiguration).Name, CurrentDomainUser.Account));
                    break;
                }

                case UpdateActionType.TenantContainerAddAll:
                {
                    entityTransformed.Containers = _unitOfWork.Repository <Container>().Queryable(true).ToList();
                    break;
                }

                case UpdateActionType.TenantContainerRemoveAll:
                {
                    entityTransformed.Containers.Clear();
                    break;
                }

                case UpdateActionType.TenantRoleAddAll:
                {
                    entityTransformed.Roles = _unitOfWork.Repository <Role>().Queryable(true).ToList();
                    break;
                }

                case UpdateActionType.TenantRoleRemoveAll:
                {
                    entityTransformed.Roles.Clear();
                    break;
                }

                case UpdateActionType.TenantContactAddAll:
                {
                    entityTransformed.Contacts = _unitOfWork.Repository <Contact>().Queryable(true).ToList();
                    break;
                }

                case UpdateActionType.TenantContactRemoveAll:
                {
                    entityTransformed.Contacts.Clear();
                    break;
                }
                }
            }

            return(base.BeforeUpdate(entity, entityTransformed));
        }
 protected override TemplateDocumentRepository BeforeUpdate(TemplateDocumentRepository entity, TemplateDocumentRepository entityTransformed)
 {
     _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entityTransformed.UniqueId, null, TableLogEvent.UPDATE, string.Concat("Modificato deposito documentale ", entity.Name), typeof(TemplateDocumentRepository).Name, CurrentDomainUser.Account));
     return(base.BeforeUpdate(entity, entityTransformed));
 }
 protected override TemplateDocumentRepository BeforeCreate(TemplateDocumentRepository entity)
 {
     _unitOfWork.Repository <TableLog>().Insert(TableLogService.CreateLog(entity.UniqueId, null, TableLogEvent.INSERT, string.Concat("Inserimento deposito documentale ", entity.Name), typeof(TemplateDocumentRepository).Name, CurrentDomainUser.Account));
     return(base.BeforeCreate(entity));
 }