public RESERVATION Add(RESERVATION entity)
        {
            RESERVATION insertedReservation = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.RES_ID = 1;

                    RESERVATION maxReservation = ctx.RESERVATIONs.OrderByDescending(s => s.RES_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxReservation))
                    {
                        entity.RES_ID = maxReservation.RES_ID + 1;
                    }

                    if (CheckHelper.IsFilled(entity.SEATs))
                    {
                        foreach (SEAT seat in entity.SEATs)
                        {
                            ctx.Entry(seat).State = EntityState.Unchanged;
                        }
                    }

                    insertedReservation = ctx.RESERVATIONs.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedReservation);
        }
 public void Delete(long id)
 {
     using (ctx = new ReadingRoomsEntities())
     {
         USER entity = ctx.USERs.Where(f => f.USR_ID == id).FirstOrDefault();
         if (CheckHelper.IsFilled(entity))
         {
             ctx.USERs.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
 public void Delete(long id)
 {
     using (ctx = new ReadingRoomsEntities())
     {
         READING_ROOM entity = ctx.READING_ROOM.Where(f => f.RROOM_ID == id).FirstOrDefault();
         if (CheckHelper.IsFilled(entity))
         {
             ctx.READING_ROOM.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
 public void Delete(long id)
 {
     using (ctx = new ReadingRoomsEntities())
     {
         UNIVERSITY entity = ctx.UNIVERSITies.Where(u => u.UNI_ID == id).FirstOrDefault();
         if (CheckHelper.IsFilled(entity))
         {
             ctx.UNIVERSITies.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
 public void Delete(long id)
 {
     using (ctx = new ReadingRoomsEntities())
     {
         RESERVATION entity = ctx.RESERVATIONs.Where(s => s.RES_ID == id).FirstOrDefault();
         if (CheckHelper.IsFilled(entity))
         {
             ctx.RESERVATIONs.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
        public USER Update(USER entity)
        {
            USER updatedUser = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedUser             = ctx.USERs.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedUser);
        }
        public READING_ROOM Update(READING_ROOM entity)
        {
            READING_ROOM updatedReadingRoom = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedReadingRoom      = ctx.READING_ROOM.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedReadingRoom);
        }
        public SEAT Update(SEAT entity)
        {
            SEAT updatedSeat = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedSeat             = ctx.SEATs.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedSeat);
        }
        public UNIVERSITY Update(UNIVERSITY entity)
        {
            UNIVERSITY updatedUni = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedUni = ctx.UNIVERSITies.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedUni);
        }
        public FACULTY Update(FACULTY entity)
        {
            FACULTY updatedFaculty = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedFaculty          = ctx.FACULTies.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedFaculty);
        }
        public RESERVATION Update(RESERVATION entity)
        {
            RESERVATION updatedReservation = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedReservation      = ctx.RESERVATIONs.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedReservation);
        }
        public USER Add(USER entity)
        {
            USER insertedUser = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.USR_ID = 1;

                    USER maxUser = ctx.USERs.OrderByDescending(f => f.USR_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxUser))
                    {
                        entity.USR_ID = maxUser.USR_ID + 1;
                    }

                    insertedUser = ctx.USERs.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedUser);
        }
        public READING_ROOM Add(READING_ROOM entity)
        {
            READING_ROOM insertedReadingRoom = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.RROOM_ID = 1;

                    READING_ROOM maxReadingRoom = ctx.READING_ROOM.OrderByDescending(f => f.RROOM_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxReadingRoom))
                    {
                        entity.RROOM_ID = maxReadingRoom.RROOM_ID + 1;
                    }

                    insertedReadingRoom = ctx.READING_ROOM.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedReadingRoom);
        }
        public SEAT Add(SEAT entity)
        {
            SEAT insertedSeat = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.SEAT_ID = 1;

                    SEAT maxSeat = ctx.SEATs.OrderByDescending(s => s.SEAT_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxSeat))
                    {
                        entity.SEAT_ID = maxSeat.SEAT_ID + 1;
                    }

                    insertedSeat = ctx.SEATs.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedSeat);
        }
        public UNIVERSITY Add(UNIVERSITY entity)
        {
            UNIVERSITY insertedUni = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.UNI_ID = 1;

                    UNIVERSITY maxUni = ctx.UNIVERSITies.OrderByDescending(u => u.UNI_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxUni))
                    {
                        entity.UNI_ID = maxUni.UNI_ID + 1;
                    }

                    insertedUni = ctx.UNIVERSITies.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedUni);
        }
        public FACULTY Add(FACULTY entity)
        {
            FACULTY insertedFaculty = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.FAC_ID = 1;

                    FACULTY maxFaculty = ctx.FACULTies.OrderByDescending(f => f.FAC_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxFaculty))
                    {
                        entity.FAC_ID = maxFaculty.FAC_ID + 1;
                    }

                    insertedFaculty = ctx.FACULTies.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedFaculty);
        }