protected override bool UpdateInternal(IUpdatableUserCollection model, UserSignUp message)
        {
            UserModel newUserData;

            try
            {
                UserData data = new UserData();
                data.UserName = message.UserName;
                data.Password = message.Password;
                data.Id       = message.Id;
                newUserData   = UserDataDBService.SignUp(data);
                var newUser = this.ModelFactoryResolver.GetFactory <IUpdatableUser>().Create();
                newUser.UserName = newUserData.UserName;
                newUser.Id       = newUserData.Id;
                model.Users.Add(newUser);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private void BuildData()
        {
            ObservableCollection <UserData> users = UserDataDBService.GetUsers();

            foreach (UserData userData in users)
            {
                var user = this.modelFactoryResolver.GetFactory <IUpdatableUser>().Create();
                user.UserName = userData.UserName;
                user.Password = userData.Password;
                user.UserName = userData.UserName;
                user.Id       = userData.Id;
                user.RebellionBoosterPacks = userData.RebellionBoosterPacks;

                ObservableCollection <MageKnightData> inventory = UserDataDBService.GetUserInventory(user.Id);
                foreach (var magedata in inventory)
                {
                    var mage = this.modelFactoryResolver.GetFactory <IUpdatableMageKnight>().Create();
                    mage.Faction    = magedata.Faction;
                    mage.FrontArc   = magedata.FrontArc;
                    mage.Id         = magedata.Id;
                    mage.Index      = magedata.Index;
                    mage.ModelImage = magedata.ModelImage;
                    mage.Name       = magedata.Name;
                    mage.PointValue = magedata.PointValue;
                    mage.Range      = magedata.Range;
                    mage.Rank       = magedata.Rank;
                    mage.Set        = magedata.Set;
                    var dial = this.modelFactoryResolver.GetFactory <IUpdatableDial>().Create();
                    foreach (var click in magedata.Dial.Clicks)
                    {
                        var query = this.modelFactoryResolver.GetFactory <IUpdatableClick>().Create();
                        query.Attack  = this.modelFactoryResolver.GetFactory <IUpdatableStat>().Create();
                        query.Speed   = this.modelFactoryResolver.GetFactory <IUpdatableStat>().Create();
                        query.Defense = this.modelFactoryResolver.GetFactory <IUpdatableStat>().Create();
                        query.Damage  = this.modelFactoryResolver.GetFactory <IUpdatableStat>().Create();

                        query.Attack.Value     = click.Attack.Value;
                        query.Attack.Ability   = click.Attack.Ability;
                        query.Attack.StatType  = click.Attack.StatType;
                        query.Speed.Value      = click.Speed.Value;
                        query.Speed.Ability    = click.Speed.Ability;
                        query.Speed.StatType   = click.Speed.StatType;
                        query.Defense.Value    = click.Defense.Value;
                        query.Defense.Ability  = click.Defense.Ability;
                        query.Defense.StatType = click.Defense.StatType;
                        query.Damage.Value     = click.Damage.Value;
                        query.Damage.Ability   = click.Damage.Ability;
                        query.Damage.StatType  = click.Damage.StatType;
                        query.Index            = click.Index;

                        foreach (var stat in click.Stats)
                        {
                            var statQuery = this.modelFactoryResolver.GetFactory <IUpdatableStat>().Create();
                            statQuery.Ability  = stat.Ability;
                            statQuery.Value    = stat.Value;
                            statQuery.StatType = stat.StatType;
                            query.Stats.Add(statQuery);
                        }

                        dial.Clicks.Add(query);
                    }

                    dial.ClickIndex = magedata.Dial.ClickIndex;
                    dial.Click      = dial.Clicks.First();
                    dial.Name       = magedata.Dial.Name;
                    mage.Dial       = dial;
                    user.Inventory.Add(mage);
                }

                this.userCollection.Users.Add(user);
            }
        }