private async void AddPerson_OnClicked(object sender, EventArgs e) { var newPersonName = PersonNameEntry.Text; if (string.IsNullOrWhiteSpace(newPersonName)) { SetInfoLabel("Name must not be empty."); return; } using (var db = new PetsDbContext()) { var existingPerson = db.People.FirstOrDefault(x => x.Name == newPersonName); if (existingPerson != null) { SetInfoLabel("A person with the same name already exists."); return; } db.People.Add(new Person { Name = newPersonName }); await db.SaveChangesAsync(); LoadPeope(); } }
public ReportService(PetsDbContext db, IMapper mapper, IPetService pet, ILocationSevices location) { this.db = db; this.mapper = mapper; this.pet = pet; this.location = location; }
private void LoadPeope() { using (var db = new PetsDbContext()) { var people = db.People.ToList(); PeopleListView.ItemsSource = people; } }
public MainPage() { InitializeComponent(); var fileName = "Pets.db"; var dbFullPath = Path.Combine(App.DbFolder, fileName); PetsDbContext.DataBasePath = dbFullPath; using (var db = new PetsDbContext()) { db.Database.Migrate(); } }
private void LoadPets() { using (var db = new PetsDbContext()) { var pets = db.Set <Animal>().ToList(); PetListView.ItemsSource = pets; _people = db.People.ToList(); OwnerPicker.Items.Clear(); foreach (var person in _people) { OwnerPicker.Items.Add(person.Name); } } }
public static void Seed(PetsDbContext dbContext, IServiceProvider serviceProvider) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } var roleManager = serviceProvider.GetRequiredService <RoleManager <ApplicationRole> >(); var userManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >(); Seed(dbContext, userManager, roleManager); }
public static void Seed(PetsDbContext dbContext, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } if (userManager == null) { throw new ArgumentNullException(nameof(userManager)); } if (roleManager == null) { throw new ArgumentNullException(nameof(roleManager)); } SeedRoles(roleManager); //SeedAdmin(userManager); }
private async void AddPet_OnClicked(object sender, EventArgs e) { var newPetName = PetNameEntry.Text; if (string.IsNullOrWhiteSpace(newPetName)) { SetInfoLabel("Name must not be empty."); return; } var ownerIndex = OwnerPicker.SelectedIndex; if (ownerIndex < 0) { SetInfoLabel("Select an owner."); return; } var owner = _people[ownerIndex]; Animal animal; if (AnimalKindPicker.SelectedIndex == 0) { animal = new Dog(); } else { animal = new Platypus(); } animal.Name = newPetName; animal.Owner = owner; using (var db = new PetsDbContext()) { db.People.Attach(owner); db.Set <Animal>().Add(animal); await db.SaveChangesAsync(); } LoadPets(); }
public PetsController(PetsDbContext petsDbContext) { _petsDbContext = petsDbContext; }
public AdoptionCatService(PetsDbContext db) { this.db = db; }
public LocationSevices(PetsDbContext db) { this.db = db; }
public PetsDbService(PetsDbContext _context) { context = _context; }
public CommentService(PetsDbContext db) { this.db = db; }
public DbService(PetsDbContext context) { _context = context; }
public EfDeletableEntityRepository(PetsDbContext context) : base(context) { }
public PetService(PetsDbContext db, IMapper mapper) { this.db = db; this.mapper = mapper; }
public PetsController(PetsDbContext db) { _db = db; }
public EfRepository(PetsDbContext context) { this.Context = context ?? throw new ArgumentNullException(nameof(context)); this.DbSet = this.Context.Set <TEntity>(); }