private void PopulateDataBase(int length = 5)
 {
     for (int i = 0; i < length; i++)
     {
         context.Add(new Character(i.ToString(), new List <string>(new string[] { "One", "Two" }), "planet", new List <Friend>(new Friend[] { new Friend {
                                                                                                                                                  Name = "LeftFriend"
                                                                                                                                              }, new Friend {
                                                                                                                                                  Name = "RightFriend"
                                                                                                                                              } })));
     }
     context.SaveChanges();
 }
Ejemplo n.º 2
0
        public void Save(CharacterContext context)
        {
            if (saveMask == AmpSaveMask.None)
            {
                return;
            }

            var model = new CharacterActionSetAmpModel
            {
                Id        = actionSet.Owner,
                SpecIndex = actionSet.Index,
                AmpId     = (byte)Entry.Id
            };

            if ((saveMask & AmpSaveMask.Create) != 0)
            {
                context.Add(model);
            }
            else if ((saveMask & AmpSaveMask.Delete) != 0)
            {
                context.Entry(model).State = EntityState.Deleted;
            }

            saveMask = AmpSaveMask.None;
        }
Ejemplo n.º 3
0
        public void Save(CharacterContext context)
        {
            if (saveMask != MailAttachmentSaveMask.None)
            {
                if ((saveMask & MailAttachmentSaveMask.Create) != 0)
                {
                    context.Add(new CharacterMailAttachmentModel
                    {
                        Id       = Id,
                        Index    = Index,
                        ItemGuid = Item.Guid
                    });
                }
                else if ((saveMask & MailAttachmentSaveMask.Delete) != 0)
                {
                    var model = new CharacterMailAttachmentModel
                    {
                        Id    = Id,
                        Index = Index
                    };

                    context.Entry(model).State = EntityState.Deleted;
                }

                saveMask = MailAttachmentSaveMask.None;
            }

            Item.Save(context);
        }
        public async Task <IActionResult> Create([Bind(
                                                      "ID," +
                                                      "Name," +
                                                      "Species," +
                                                      "Gender," +
                                                      "Faction," +
                                                      "Homeworld," +
                                                      "Background," +
                                                      "Class," +
                                                      "PartialClasses," +
                                                      "Strength," +
                                                      "StrengthModifierBonus," +
                                                      "Dexterity," +
                                                      "DexterityModifierBonus," +
                                                      "Constitution," +
                                                      "ConstitutionModifierBonus," +
                                                      "Intelligence," +
                                                      "IntelligenceModifierBonus," +
                                                      "Wisdom," +
                                                      "WisdomModifierBonus," +
                                                      "Charisma" +
                                                      "CharismaModifierBonus,")] Character character)
        {
            if (ModelState.IsValid)
            {
                _context.Add(character);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(character));
        }
Ejemplo n.º 5
0
        public void Save(CharacterContext context)
        {
            if (saveMask == SaveMask.None)
            {
                return;
            }

            var model = new CharacterEntitlementModel
            {
                Id            = characterId,
                EntitlementId = (byte)Type,
                Amount        = amount
            };

            if ((saveMask & SaveMask.Create) != 0)
            {
                context.Add(model);
            }
            else
            {
                EntityEntry <CharacterEntitlementModel> entity = context.Attach(model);
                entity.Property(p => p.Amount).IsModified = true;
            }

            saveMask = SaveMask.None;
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ID,Name,Url,Gender,Culture,Born,Died,Father,Mother,Spouse")] Character character)
        {
            if (ModelState.IsValid)
            {
                _context.Add(character);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(character));
        }
 public IActionResult CreateNewCharacter(Character character)
 {
     try
     {
         _context.Add(character);
         _context.SaveChanges();
     }
     catch (System.Exception ex)
     {
         throw new UserFriendlyException(ex.Message);
     }
     return(Created(character.Name, new { name = character.Name }));
 }
Ejemplo n.º 8
0
        public void Save(CharacterContext context)
        {
            foreach ((ushort hexGroupId, bool _) in zoneMapHexGroups.Where(z => z.Value).ToList())
            {
                var model = new CharacterZonemapHexgroupModel
                {
                    Id       = player.CharacterId,
                    ZoneMap  = (ushort)entry.Id,
                    HexGroup = hexGroupId
                };

                context.Add(model);
                zoneMapHexGroups[hexGroupId] = false;
            }
        }
Ejemplo n.º 9
0
        public void Save(CharacterContext context)
        {
            if (!isDirty)
            {
                return;
            }

            var model = new CharacterPetFlair
            {
                Id         = Owner,
                PetFlairId = Entry.Id
            };

            context.Add(model);
            isDirty = false;
        }
Ejemplo n.º 10
0
        public override void Save(CharacterContext context)
        {
            if (saveMask == SaveMask.None)
            {
                return;
            }

            if ((saveMask & SaveMask.Create) != 0)
            {
                context.Add(new CharacterAchievementModel
                {
                    Id            = characterId,
                    AchievementId = Id,
                    Data0         = Data0,
                    Data1         = Data1,
                    DateCompleted = DateCompleted
                });
            }
            else
            {
                var model = new CharacterAchievementModel
                {
                    Id            = characterId,
                    AchievementId = Id
                };

                EntityEntry <CharacterAchievementModel> entity = context.Attach(model);
                if ((saveMask & SaveMask.Data0) != 0)
                {
                    model.Data0 = Data0;
                    entity.Property(p => p.Data0).IsModified = true;
                }
                if ((saveMask & SaveMask.Data1) != 0)
                {
                    model.Data1 = Data1;
                    entity.Property(p => p.Data1).IsModified = true;
                }
                if ((saveMask & SaveMask.TimeCompleted) != 0)
                {
                    model.DateCompleted = DateCompleted;
                    entity.Property(p => p.DateCompleted).IsModified = true;
                }
            }

            saveMask = SaveMask.None;
        }
Ejemplo n.º 11
0
        static void CreateNewCharacter()
        {
            Console.WriteLine("Character Name:");
            string characterName = Console.ReadLine();

            Console.WriteLine("Character Health:");
            int characterHealth = int.Parse(Console.ReadLine());

            Console.WriteLine("Character Attack:");
            int characterAttack = int.Parse(Console.ReadLine());

            Console.WriteLine("Create (y/n)");
            if (Console.ReadLine() == "y")
            {
                Character character = new Character(characterHealth, characterAttack, characterName);

                characterContext.Add(character);
                characterContext.SaveChanges();
            }
            ModeSelection();
        }
Ejemplo n.º 12
0
        public void Save(CharacterContext context)
        {
            if ((saveMask & BindingSaveMask.Create) != 0)
            {
                var model = new CharacterKeybinding
                {
                    Id              = Owner,
                    InputActionId   = InputActionId,
                    DeviceEnum00    = DeviceEnum00,
                    DeviceEnum01    = DeviceEnum01,
                    DeviceEnum02    = DeviceEnum02,
                    Code00          = Code00,
                    Code01          = Code01,
                    Code02          = Code02,
                    MetaKeys00      = MetaKeys00,
                    MetaKeys01      = MetaKeys01,
                    MetaKeys02      = MetaKeys02,
                    EventTypeEnum00 = EventTypeEnum00,
                    EventTypeEnum01 = EventTypeEnum01,
                    EventTypeEnum02 = EventTypeEnum02
                };
                context.Add(model);
            }
            else
            {
                var model = new CharacterKeybinding
                {
                    Id            = Owner,
                    InputActionId = InputActionId
                };

                if ((saveMask & BindingSaveMask.Delete) != 0)
                {
                    context.Entry(model).State = EntityState.Deleted;
                }
                else
                {
                    EntityEntry <CharacterKeybinding> entity = context.Attach(model);

                    if ((saveMask & BindingSaveMask.DeviceEnum00) != 0)
                    {
                        model.DeviceEnum00 = DeviceEnum00;
                        entity.Property(p => p.DeviceEnum00).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.DeviceEnum01) != 0)
                    {
                        model.DeviceEnum01 = DeviceEnum01;
                        entity.Property(p => p.DeviceEnum01).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.DeviceEnum02) != 0)
                    {
                        model.DeviceEnum02 = DeviceEnum02;
                        entity.Property(p => p.DeviceEnum02).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.Code00) != 0)
                    {
                        model.Code00 = Code00;
                        entity.Property(p => p.Code00).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.Code01) != 0)
                    {
                        model.Code01 = Code01;
                        entity.Property(p => p.Code01).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.Code02) != 0)
                    {
                        model.Code02 = Code02;
                        entity.Property(p => p.Code02).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.MetaKeys00) != 0)
                    {
                        model.MetaKeys00 = MetaKeys00;
                        entity.Property(p => p.MetaKeys00).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.MetaKeys01) != 0)
                    {
                        model.MetaKeys01 = MetaKeys01;
                        entity.Property(p => p.MetaKeys01).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.MetaKeys02) != 0)
                    {
                        model.MetaKeys02 = MetaKeys02;
                        entity.Property(p => p.MetaKeys02).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.EventTypeEnum00) != 0)
                    {
                        model.EventTypeEnum00 = EventTypeEnum00;
                        entity.Property(p => p.EventTypeEnum00).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.EventTypeEnum01) != 0)
                    {
                        model.EventTypeEnum01 = EventTypeEnum01;
                        entity.Property(p => p.EventTypeEnum01).IsModified = true;
                    }

                    if ((saveMask & BindingSaveMask.EventTypeEnum02) != 0)
                    {
                        model.EventTypeEnum02 = EventTypeEnum02;
                        entity.Property(p => p.EventTypeEnum02).IsModified = true;
                    }

                    saveMask = BindingSaveMask.None;
                }
            }
        }