public static Department Parse(SerializableDepartment department)
        {
            if (department == null)
            {
                return(null);
            }

            return(new Department(department.Id, department.Name, department.ManagerId)
            {
                ParentUnit = department.ParentUnit,
                StaffList = department.StaffList.Select(x => SerializableStaff.Parse(x)).ToList(),
                UnitList = department.UnitList
            });
        }
Exemple #2
0
        public static Section Parse(SerializableSection section)
        {
            if (section == null)
            {
                return(null);
            }

            List <Unit> subUnits = new List <Unit>();

            foreach (var subUnit in section.SubUnits)
            {
                if (subUnit is SerializableSection)
                {
                    subUnits.Add(SerializableSection.Parse(subUnit as SerializableSection));
                }

                if (subUnit is SerializableTeam)
                {
                    subUnits.Add(SerializableTeam.Parse(subUnit as SerializableTeam));
                }
            }

            OrganizationUnit parentUnit = null;

            if (section.ParentUnit is SerializableSection)
            {
                parentUnit = SerializableSection.Parse(section.ParentUnit as SerializableSection);
            }
            if (section.ParentUnit is SerializableDepartment)
            {
                parentUnit = SerializableDepartment.Parse(section.ParentUnit as SerializableDepartment);
            }

            return(new Section(section.Id, section.Name, section.ParentUnitId, section.AuthorId)
            {
                Department = SerializableDepartment.Parse(section.Department),
                ParentUnit = parentUnit,
                StaffList = section.StaffList.Select(x => SerializableStaff.Parse(x)).ToList(),
                SubUnits = subUnits
            });
        }
Exemple #3
0
        public static Team Parse(SerializableTeam team)
        {
            if (team == null)
            {
                return(null);
            }

            OrganizationUnit parentUnit = null;

            if (team.ParentUnit is SerializableSection)
            {
                parentUnit = SerializableSection.Parse(team.ParentUnit as SerializableSection);
            }
            if (team.ParentUnit is SerializableDepartment)
            {
                parentUnit = SerializableDepartment.Parse(team.ParentUnit as SerializableDepartment);
            }

            return(new Team(team.Id, team.Name, team.SectionId, team.DepartmentId, team.TeamLeadId)
            {
                ParentUnit = parentUnit,
                StaffList = team.StaffList.Select(x => SerializableStaff.Parse(x)).ToList(),
            });
        }
        public static List <Staff> DeserializeStaffList(string json)
        {
            var serializer = new SerializableStaff();

            return(serializer.DeserializeList(json));
        }
        public static Staff DeserializeStaff(string json)
        {
            var serializer = new SerializableStaff();

            return(serializer.Deserialize(json));
        }
Exemple #6
0
        public static Staff Parse(SerializableStaff staff)
        {
            if (staff == null)
            {
                return(null);
            }

            UserCard    userCard    = null;
            User        user        = null;
            Position    position    = null;
            Credentials credentials = null;
            Department  department  = null;
            Section     section     = null;
            Team        team        = null;

            if (staff.ErtisUser != null && staff.ErtisUser.Card != null)
            {
                userCard = SerializableUserCard.Parse(staff.ErtisUser.Card);
            }

            if (staff.ErtisUser != null)
            {
                user = SerializableUser.Parse(staff.ErtisUser);
            }

            if (staff.Position != null)
            {
                position = SerializablePosition.Parse(staff.Position);
            }

            if (staff.UserCredentials != null)
            {
                credentials = SerializableCredentials.Parse(staff.UserCredentials);
            }

            if (staff.Department != null)
            {
                department = SerializableDepartment.Parse(staff.Department);
            }

            if (staff.Section != null)
            {
                section = SerializableSection.Parse(staff.Section);
            }

            if (staff.Team != null)
            {
                team = SerializableTeam.Parse(staff.Team);
            }

            return(new Staff(staff.Id, user, position)
            {
                PositionId = staff.PositionId,
                UserId = staff.UserId,
                CredentialsId = staff.CredentialsId,
                UserCredentials = credentials,
                DepartmentId = staff.DepartmentId,
                Department = department,
                Section = section,
                SectionId = staff.SectionId,
                Team = team,
                TeamId = staff.TeamId
            });
        }