Esempio n. 1
0
        public virtual async Task SetUserTournamentPropertyValueAsync(User user, UserProperty property, Tournament tournament, String value)
        {
            var repository = unitOfWork.GetRepository<UserTournamentPropertyValue>();
            if (user != null && property != null && tournament != null)
            {
                var userTournamentPropertyValue = repository.GetById(user.Id, property.Id, tournament.Id);
                if (userTournamentPropertyValue == null)
                {
                    userTournamentPropertyValue = new UserTournamentPropertyValue
                    {
                        User = user,
                        Tournament = tournament,
                        UserProperty = property,
                        Value = value
                    };
                    repository.Insert(userTournamentPropertyValue);
                }
                else
                {
                    userTournamentPropertyValue.Value = value;
                    repository.Update(userTournamentPropertyValue);
                }
                await unitOfWork.SaveAsync();
            }

        }
Esempio n. 2
0
        private UserPropertyValueViewModel CreateUserPropertyValueViewModel(UserProperty userProperty, String value, User user)
        {

            // If not value is provided, build an empty value

            var propertyValue = new UserPropertyValue
            {
                User = user,
                UserId = user.Id,
                UserProperty = userProperty,
                UserPropertyId = userProperty.Id,
                Value = value
            };

            // Build view model for property value

            var propertyViewModel = new UserPropertyValueViewModel(propertyValue);

            // If type is country, build country list

            if (userProperty.Type == PropertyType.Country)
            {
                propertyViewModel.CreateCountryList(countryManager.GetCountries());
            }
            return propertyViewModel;
        }