Example #1
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
            });
        }
Example #2
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 <Team> DeserializeTeamList(string json)
        {
            var serializer = new SerializableTeam();

            return(serializer.DeserializeList(json));
        }
        public static Team DeserializeTeam(string json)
        {
            var serializer = new SerializableTeam();

            return(serializer.Deserialize(json));
        }
Example #5
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
            });
        }