Пример #1
0
        public UserPropertyValue(DebReg.Models.UserPropertyValue propertyValue)
            : this()
        {
            if (propertyValue != null)
            {
                this.userId = propertyValue.UserId;
                this.propertyId = propertyValue.UserPropertyId;
                this.name = propertyValue.UserProperty.Name;
                this.value = propertyValue.Value;
                this.displayValue = propertyValue.Value;

                if (propertyValue.UserProperty.Type == DebReg.Models.PropertyType.SingleSelect ||
                    propertyValue.UserProperty.Type == DebReg.Models.PropertyType.Country)
                {
                    Guid optionId;
                    if (Guid.TryParse(propertyValue.Value, out optionId))
                    {
                        var option = propertyValue.UserProperty.Options.FirstOrDefault(o =>
                            o.Id == optionId);
                        if (option != null)
                        {
                            this.displayValue = option.Name;
                        }
                    }

                }

                // TODO: Implement DisplayValue for person type

            }
        }
Пример #2
0
 public Adjudicator(DebReg.Models.Adjudicator adjudicator)
 {
     tournamentId = adjudicator.TournamentId;
     organizationId = adjudicator.OrganizationId;
     userId = adjudicator.UserId;
     user = new User(adjudicator.User, tournamentId);
     organization = new Organization(adjudicator.Organization);
 }
Пример #3
0
 public Tournament(DebReg.Models.Tournament tournament)
     : this()
 {
     id = tournament.Id;
     name = tournament.Name;
     start = tournament.Start;
     end = tournament.End;
     registrationStart = tournament.RegistrationStart;
     registrationEnd = tournament.RegistrationEnd;
 }
Пример #4
0
 public User(DebReg.Models.User user, Guid tournamentId)
     : this(user)
 {
     var tournamentProperties = user.TournamentPropertyValues.Where(v => v.TournamentId == tournamentId);
     foreach (var tournamentProperty in tournamentProperties)
     {
         var value = GetPropertyValue(tournamentProperty.Value, tournamentProperty.UserProperty);
         properties.Add(tournamentProperty.UserProperty.Name, value);
         propertyValues.Add(new UserPropertyValue(tournamentProperty));
     }
 }
Пример #5
0
 public Organization(DebReg.Models.Organization organization)
     : base()
 {
     this.id = organization.Id;
     this.name = organization.Name;
     this.abbreviation = organization.Abbreviation;
     this.university = organization.University;
     this.address = new Address(organization.Address);
     this.linkedOrganizations = organization.LinkedOrganizations
         .Select(o => new Organization(o))
         .ToList();
 }
Пример #6
0
 public UserPropertyValue(DebReg.Models.UserTournamentPropertyValue propertyValue)
     : this()
 {
     if (propertyValue != null)
     {
         this.userId = propertyValue.UserId;
         this.propertyId = propertyValue.UserPropertyId;
         this.tournamentId = propertyValue.TournamentId;
         this.name = propertyValue.UserProperty.Name;
         this.value = propertyValue.Value;
     }
 }
Пример #7
0
 public Team(DebReg.Models.Team team)
     : this()
 {
     this.id = team.Id;
     this.tournamentId = team.TournamentId;
     this.organizationId = team.OrganizationId;
     this.organization = new Organization(team.Organization);
     this.name = team.Name;
     foreach (var speaker in team.Speaker)
     {
         speakers.Add(new User(speaker, tournamentId));
     }
 }
Пример #8
0
        public Tournament(DebReg.Models.Tournament tournament, DebReg.Models.User user) :
            this(tournament)
        {
            var roles = from role in user.TournamentRoles
                        where role.TournamentId == tournament.Id
                        select role;

            foreach (var role in roles)
            {
                TournamentRole tournamentRole;
                switch (role.Role)
                {
                    case DebReg.Models.TournamentRole.SlotManager:
                        tournamentRole = TournamentRole.Manager;
                        break;
                    case DebReg.Models.TournamentRole.OrganizationApprover:
                        tournamentRole = TournamentRole.Manager;
                        break;
                    case DebReg.Models.TournamentRole.FinanceManager:
                        tournamentRole = TournamentRole.Manager;
                        break;
                    default:
                        tournamentRole = TournamentRole.None;
                        break;
                }

                if (!this.roles.Any(r => r == tournamentRole))
                {
                    this.roles.Add(tournamentRole);

                }

            }

            if (user.Teams.Any(t => t.TournamentId == tournament.Id))
            {
                this.roles.Add(TournamentRole.Speaker);
            }

            if (user.Adjudicator.Any(a => a.TournamentId == tournament.Id))
            {
                this.roles.Add(TournamentRole.Adjudicator);
            }
        }
Пример #9
0
        private string GetPropertyValue(String value, DebReg.Models.UserProperty userProperty)
        {
            var returnValue = value;
            if (userProperty.Type == DebReg.Models.PropertyType.SingleSelect ||
                userProperty.Type == DebReg.Models.PropertyType.Country)
            {
                Guid optionId;
                if (Guid.TryParse(value, out optionId))
                {
                    var option = userProperty.Options.FirstOrDefault(o =>
                        o.Id == optionId);
                    if (option != null)
                    {
                        returnValue = option.Name;
                    }
                }

            }
            return returnValue;
        }
Пример #10
0
        public User(DebReg.Models.User user)
            : this()
        {
            if (user != null)
            {
                id = Guid.Parse(user.Id);
                firstname = user.FirstName;
                lastname = user.LastName;
                eMail = user.Email;
                phoneNumber = user.PhoneNumber;

                foreach (var propertyValue in user.PropertyValues)
                {
                    propertyValues.Add(new UserPropertyValue(propertyValue));

                    var value = GetPropertyValue(propertyValue.Value, propertyValue.UserProperty);
                    properties.Add(propertyValue.UserProperty.Name, value);
                }

            }
        }
Пример #11
0
        public IList<SlotAssignment> GetSlotAssignments(Guid tournamentId, DebReg.Models.Version version, User user)
        {
            var waitList = tournamentregistrationsManager.GetRegistrationsSortedByRank(tournamentId, user);
            // List<SlotAssignment> assignments = new List<SlotAssignment>();

            var assignments = slotAssignmentManager.GetSlotAssignments(tournamentId, version.Id).ToList();
            IList<SlotAssignment> result = new List<SlotAssignment>();

            // Create missing assignments

            foreach (var registration in waitList)
            {
                var currentAssignment = assignments.FirstOrDefault(a => a.OrganizationId == registration.OrganizationId);

                if (currentAssignment == null)
                {
                    currentAssignment = new SlotAssignment
                    {
                        Organization = registration.Organization,
                        OrganizationId = registration.OrganizationId,
                        TournamentId = registration.TournamentId,
                        TeamsGranted = 0,
                        AdjucatorsGranted = 0,
                        Version = version
                    };
                }
                result.Add(currentAssignment);
            }
            return assignments;
        }