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(); } } }
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(); }
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); }