Ejemplo n.º 1
0
        public Person CreateNewPerson()
        {
            StringInputDialog addPersonDialog = new StringInputDialog
            {
                Title   = "Creazione nuova Persona",
                Message = "Nome:"
            };

            if (addPersonDialog.ShowDialog() != true)
            {
                return(null);
            }

            Person newPerson = new Person
            {
                Name = addPersonDialog.InputString
            };

            foreach (PersonRole prr in _lInstData.RunQuery(new PersonRolesQuery()))
            {
                PersonRoleMapping tempPRM = new PersonRoleMapping();
                tempPRM.RoleID     = prr.ID;
                tempPRM.IsSelected = false;
                newPerson.RoleMappings.Add(tempPRM);
            }

            _lInstData.Execute(new InsertEntityCommand <LInstContext>(newPerson));

            return(newPerson);
        }
Ejemplo n.º 2
0
        public PersonRole CreateNewPersonRole()
        {
            StringInputDialog addPersonRoleDialog = new StringInputDialog();

            addPersonRoleDialog.Title   = "Creazione nuovo Ruolo Persona";
            addPersonRoleDialog.Message = "Nome:";

            if (addPersonRoleDialog.ShowDialog() != true)
            {
                return(null);
            }

            PersonRole newRole = new PersonRole
            {
                Name        = addPersonRoleDialog.InputString,
                Description = ""
            };

            using (LInstContext entities = _dbContextFactory.CreateDbContext(new string[] { }))
            {
                entities.PersonRoles.Add(newRole);

                foreach (Person per in entities.People)
                {
                    PersonRoleMapping newMapping = new PersonRoleMapping
                    {
                        Person     = per,
                        IsSelected = false
                    };
                    newRole.RoleMappings.Add(newMapping);
                }

                entities.SaveChanges();
            }

            return(newRole);
        }