private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialog = new DialogResult(); dialog = MessageBox.Show("Silmek istiyor musunuz?", "Silme Onayı", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { using (CarParkDbContext db = new CarParkDbContext()) { int id = int.Parse(dataGridCustomerList.CurrentRow.Cells[0].Value.ToString()); var customer = db.Customers .Include(x => x.CarParkingSpaces) .FirstOrDefault(x => x.Id == id); if (customer != null) { customer.Deleted = true; customer.CarParkingSpaces.Status = false; db.SaveChanges(); MessageBox.Show("Kayıt silindi", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information); Clean(); GridFill(); } else { MessageBox.Show("Müşteri bulunamadı", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void GridFill() { using (CarParkDbContext db = new CarParkDbContext()) { dataGridCustomerList.DataSource = db.Customers .Include(x => x.Brand) .Include(x => x.Serie) .Include(x => x.CarParkingSpaces) .Where(x => !x.Deleted) .Select(x => new { x.Id, x.NameSurname, x.Plaque, SerieName = x.Serie.SerieName, BrandName = x.Brand.BrandName, ParkingSpaces = x.CarParkingSpaces.ParkingSpaces, x.Color, x.Comment, x.EntryDate, x.Telephone, x.Year }).ToList(); } }
private static void SetDbContext() { var options = new DbContextOptionsBuilder <CarParkDbContext>() .UseInMemoryDatabase("CarParkDb") .Options; _carParkDbContext = new CarParkDbContext(options); }
private void txtSearch_TextChanged(object sender, EventArgs e) { using (CarParkDbContext db = new CarParkDbContext()) { if (!string.IsNullOrEmpty(txtSearch.Text)) { dataGridCustomerList.DataSource = db.Customers.Where(x => x.Plaque.Contains(txtSearch.Text)).ToList(); } else { GridFill(); } } }
public CarParkingSpaceService(CarParkDbContext context) { this.context = context; }
public SerieService(CarParkDbContext context) { this.context = context; }
public BrandService(CarParkDbContext context) { this.context = context; }
public CustomerService(CarParkDbContext context) { this.context = context; }
public UserController(IOptions <SettingsModel> app, CarParkDbContext context) { appSettings = app; _context = context; _applicationservice = applicationservice; }
public UserService(CarParkDbContext context) { this.context = context; }
public TariffService(CarParkDbContext context) { this.context = context; }