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 AddNinja() { var ninja = new NinjaViewModel() { Gold = Gold, Name = Name }; if (!NinjaRepository.Add(ninja)) { return; } Ninja.UpdateCollection(); Close(); }
public void InsertNinjaWithoutClan() { //inicializa a injeção de dependencia SimpleInjectorContainer.RegisterServices(); INinjaRepository ninjaRepository = new NinjaRepository(); Ninja ninja = new Ninja { NinjaName = "Bolacha", DateCreated = DateTime.Now, DateModified = DateTime.Now }; if (!ninjaRepository.FindBy(n => n.NinjaName == ninja.NinjaName).Any()) { ninjaRepository.Add(ninja); ninjaRepository.Save(); } }