public bool InsertSeats(int projid, int viewerid, int seats, int r, int c) { int maxRow = 6; int maxCol = 5; bool result = false; using (var tran = db.Database.BeginTransaction(System.Data.IsolationLevel.RepeatableRead)) { for (int i = 0; i < seats; i++) { c++; if (c > maxCol) { c = 1; r++; } if (r > maxRow) { result = false; tran.Rollback(); } var toInsert = new DbSeatReservation() { ProjectionId = projid, ViewerId = viewerid, Row = r, Column = c }; db.Reservations.Add(toInsert); } result = true; db.SaveChanges(); tran.Commit(); } return(result); }
private static Model.SeatReservation ToModel(DbSeatReservation value) { return(new Model.SeatReservation(value.Id, value.ProjectionId, value.ViewerId, value.Row, value.Column)); }