public Projection Delete(int projId)
        {
            var dbProjection = db.Projections.FirstOrDefault(t => t.Id == projId);

            if (dbProjection == null)
            {
                return(null);
            }
            else
            {
                db.Projections.Remove(dbProjection);
                db.SaveChanges();

                return(ToModel(dbProjection));
            }
        }
Exemple #2
0
        public Film Delete(int filmId)
        {
            var dbFilm = db.Films.FirstOrDefault(f => f.Id == filmId);

            if (dbFilm == null)
            {
                return(null);
            }
            else
            {
                db.Films.Remove(dbFilm);
                db.SaveChanges();

                return(ToModel(dbFilm));
            }
        }
Exemple #3
0
        public Viewer Delete(int viewerId)
        {
            var dbViewer = db.Viewers.FirstOrDefault(t => t.Id == viewerId);

            if (dbViewer == null)
            {
                return(null);
            }
            else
            {
                db.Viewers.Remove(dbViewer);
                db.SaveChanges();

                return(ToModel(dbViewer));
            }
        }
Exemple #4
0
        public Room Delete(int roomId)
        {
            var dbRoom = db.Rooms.FirstOrDefault(r => r.Id == roomId);

            if (dbRoom == null)
            {
                return(null);
            }
            else
            {
                db.Rooms.Remove(dbRoom);
                db.SaveChanges();

                return(ToModel(dbRoom));
            }
        }
Exemple #5
0
        public Order Delete(int orderId)
        {
            var dbOrder = db.Orders.FirstOrDefault(o => o.Id == orderId);

            if (dbOrder == null)
            {
                return(null);
            }
            else
            {
                db.Orders.Remove(dbOrder);
                db.SaveChanges();

                return(ToModel(dbOrder));
            }
        }
Exemple #6
0
        public Seat Delete(int seatId)
        {
            var dbSeat = db.Seats.FirstOrDefault(t => t.Id == seatId);

            if (dbSeat == null)
            {
                return(null);
            }
            else
            {
                db.Seats.Remove(dbSeat);
                db.SaveChanges();

                return(ToModel(dbSeat));
            }
        }
        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);
        }