public bool Delete(Company company) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { context.Companies.Remove(company); context.SaveChanges(); return(true); } } catch { return(false); } }
public int Add(Company company) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { context.Companies.Add(company); context.SaveChanges(); return(company.CompanyId); } } catch { return(-1); } }
public bool Add(Reservation reservation) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { context.Reservations.Add(reservation); context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Add(Court court) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { context.Courts.Add(court); context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Delete(User user) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { context.Users.Remove(user); context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Update(Court court, Court updated) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { court.CourtName = updated.CourtName; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Update(Reservation reservation, Reservation updated) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { reservation.StartTime = updated.StartTime; reservation.EndTime = updated.EndTime; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Update(User user, User updated) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { user.FirstName = updated.FirstName; user.LastName = updated.LastName; user.PhoneNumber = updated.PhoneNumber; user.Password = updated.Password; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Update(Company company, Company updated) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { company.CompanyName = updated.CompanyName; company.Description = updated.Description; company.Latitude = updated.Latitude; company.Longitude = updated.Longitude; company.PhoneNumber = updated.PhoneNumber; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Delete(int reservationId, int userId) { try { using (var context = new SportivoContext(new DbContextOptions <SportivoContext>())) { var reservation = context.Reservations.FirstOrDefault(r => r.ReservationId == reservationId); var user = context.Users.FirstOrDefault(u => u.UserId == userId); if (reservation.UserId == userId || reservation.Court.CompanyId == user.CompanyId) { context.Reservations.Remove(reservation); context.SaveChanges(); return(true); } return(false); } } catch { return(false); } }