Exemplo n.º 1
0
        public void CharacterMapper_MapCombatCMToHealthRecord()
        {
            CombatCM cm = new CombatCM();

            cm.MaxHP = 50;

            Health actual = CharacterMapper.mapCombatCMToNewHealthEntity(cm);

            actual.MaxHP.Should().Be(cm.MaxHP);
        }
        public void CreateCharacterPOST(Guid user_id, CharacterVM vm)
        {
            Guid character_id = Guid.NewGuid();
            CreateModelMapper <PrimaryTabVM, CharacterDM> characterMapper = new CreateModelMapper <PrimaryTabVM, CharacterDM>();
            CreateModelMapper <CombatCM, CharacterDM>     combatMapper    = new CreateModelMapper <CombatCM, CharacterDM>();
            CharacterDM character = characterMapper.mapViewModelToDataModel(vm.PrimaryTab);

            if (_commons.raceExists(vm.PrimaryTab.Race) == true)
            {
                character.Race_id = vm.PrimaryTab.Race;
            }
            ;
            combatMapper.mapViewModelToDataModel(vm.PrimaryTab.Combat, character);


            character.Character_id = character_id;
            Health       health = CharacterMapper.mapCombatCMToNewHealthEntity(vm.PrimaryTab.Combat);
            IsProficient skills = mapIsProficient(vm.PrimaryTab.Skills.isProficient);
            CreateModelMapper <SavesCM, IsProficient> mapSaves = new CreateModelMapper <SavesCM, IsProficient>();

            mapSaves.mapViewModelToDataModel(vm.PrimaryTab.Saves, skills);
            Stats    stats = CharacterMapper.mapStatsCMToNewEntity(vm.PrimaryTab.Stats);
            Currency money = CharacterMapper.mapCurrencyCMToNewEntity(vm.InventoryTab.Money);

            character.Character_id = character_id;
            character.User_id      = user_id;
            health.Character_id    = character_id;
            stats.Character_id     = character_id;
            skills.Character_id    = character_id;
            money.Character_id     = character_id;

            _userAccess.AddCharacter(character);
            _userAccess.AddHealthRecord(health);
            _userAccess.AddStatsRecord(stats);
            _userAccess.AddProficiencyRecord(skills);
            _userAccess.AddCurrencyRecord(money);
            LearnSpells(vm.SpellsTab.KnownSpells, character_id);
            SetInventory(vm.InventoryTab.Items, character_id);
            SetNotes(vm.NotesTab.Notes, character_id);
            SetClasses(vm.PrimaryTab.Classes.SelectedClasses, character_id);
            _userAccess.SaveChanges();
        }