示例#1
0
        public void InsertNinja()
        {
            //inicializa a injeção de dependencia
            //SimpleInjectorContainer.RegisterServices();

            INinjaRepository     ninjaRepository     = new NinjaRepository();
            INinjaClanRepository ninjaClanRepository = new NinjaClanRepository();

            var ninjaClan = ninjaClanRepository.FindBy(nc => nc.ClanName == "Camargo's").FirstOrDefault();

            if (ninjaClan != null)
            {
                Ninja ninja = new Ninja
                {
                    NinjaName    = "Bruna",
                    DateCreated  = DateTime.Now,
                    DateModified = DateTime.Now,
                    NinjaClanId  = ninjaClan.Id
                };

                if (!ninjaRepository.FindBy(n => n.NinjaName == ninja.NinjaName).Any())
                {
                    ninjaRepository.Add(ninja);
                    ninjaRepository.Save();
                }
            }
        }
示例#2
0
        public void UpdateNinjaAndClan()
        {
            var ninjaRepository     = new NinjaRepository();
            var ninjaClanRepository = new NinjaClanRepository();

            var ninja     = ninjaRepository.GetById(1);
            var ninjaClan = ninjaClanRepository.GetById(ninja.NinjaClanId);

            ninja.NinjaName = "Murilo Cesar";
            ninjaRepository.Update(ninja);
            ninjaRepository.Save();

            ninjaClan.ClanName = "Gafanhotos";

            ninjaClanRepository.Update(ninjaClan);
            ninjaClanRepository.Save();
        }
示例#3
0
        public void InserNinjaClan()
        {
            SimpleInjectorContainer.RegisterServices();

            INinjaClanRepository ninjaClanRepository = new NinjaClanRepository();

            NinjaClan ninjaClan = new NinjaClan
            {
                DateModified   = DateTime.Now,
                DateCreated    = DateTime.Now,
                ClanName       = "Camargo's",
                FoundationDate = DateTime.Today
            };

            if (!ninjaClanRepository.FindBy(clan => clan.ClanName == ninjaClan.ClanName).Any())
            {
                ninjaClanRepository.Add(ninjaClan);
                ninjaClanRepository.Save();
            }

            Console.WriteLine(ninjaClan.Id);
        }