public void ShouldAddNewReservation_ReturnNewID() { SqlLiteDB.SqlLiteDBCreateTableIFNotExist(); int reservationID = selectReservation.GetNextTabletId(SGetIdFromSpecificTable.queryGetLatestReservationID()); Reservation reservation = new Reservation() { reservation_id = reservationID, reservation_date = new DateTime(2020, 7, 17, 12, 1, 1), reservation_time = new TimeSpan(11, 5, 0), client_id = 2, services_id = 2 }; int lastIndex = addReservation.InsertObjectToDB(reservation); Assert.AreEqual(lastIndex, reservationID); }
public bool GetReservationIdAndInsertToDB(DateTime reservationDate, int reservationHour, int reservationMinute, int clientID, int servicesID, int employeeID) { int reservationID = selectReservation.GetNextTabletId(SGetIdFromSpecificTable.queryGetLatestReservationID()); Reservation reservation = new Reservation() { reservation_id = reservationID, reservation_date = reservationDate, reservation_time = new TimeSpan(reservationHour, reservationMinute, 0), client_id = clientID, services_id = servicesID, employee_id = employeeID }; if (selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery()) .Any(x => x.reservation_date == reservation.reservation_date && x.reservation_time == reservation.reservation_time && x.employee_id == reservation.employee_id)) { return(false); } SLogToFile.SaveDataTebleInToFile("reservation", reservation.ToString()); insertReservation.InsertObjectToDB(reservation); return(true); }