Exemple #1
0
        void IService <SuperpowerDTO> .Create(SuperpowerDTO dto)
        {
            var destination = new SuperpowerModel
            {
                Nazev = dto.Nazev
            };

            _context.Superschopnosti.Add(destination);
            _context.SaveChanges();

            foreach (var superheroId in dto.SuperheroesIds)
            {
                var jtHeroPower = new jt_superhero_superpower
                {
                    SuperpowerId = destination.Id,
                    SuperheroId  = superheroId
                };

                _context.jtHeroPower.Add(jtHeroPower);
                _context.SaveChanges();
            }
        }
Exemple #2
0
        void IService <SuperheroDTO> .Create(SuperheroDTO dto)
        {
            SuperheroModel destination = new SuperheroModel
            {
                Jmeno    = dto.Jmeno,
                Prijmeni = dto.Prijmeni
            };

            _context.Superheroes.Add(destination);
            _context.SaveChanges();

            foreach (var superpowerId in dto.SuperschopnostiIds)
            {
                var jtHeroPower = new jt_superhero_superpower
                {
                    SuperheroId  = destination.Id,
                    SuperpowerId = superpowerId
                };

                _context.jtHeroPower.Add(jtHeroPower);
                _context.SaveChanges();
            }
        }