public ReservationDTO TransformToDTO(RESERVATION entry)
        {
            ReservationDTO            dto   = null;
            READING_ROOM              rroom = null;
            ReadingRoomRepositoryImpl repo  = new ReadingRoomRepositoryImpl();

            if (CheckHelper.IsFilled(entry.SEATs))
            {
                rroom = repo.GetById(entry.SEATs.ToList()[0].RROOM_ID);
            }


            if (CheckHelper.IsFilled(entry))
            {
                dto = new ReservationDTO()
                {
                    Id          = entry.RES_ID,
                    ETA         = entry.RES_ETA,
                    ETD         = entry.RES_ETD,
                    UserId      = entry.USR_ID,
                    ReadingRoom = new ReadingRoomTransformer().TransformToDTO(rroom)
                };
            }

            return(dto);
        }
 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 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 READING_ROOM GetById(long id)
        {
            READING_ROOM faculty = null;

            using (ctx = new ReadingRoomsEntities())
            {
                if (id > 0)
                {
                    faculty = ctx.READING_ROOM
                              .Where(rr => rr.RROOM_ID == id)
                              .Include(rr => rr.UNIVERSITY)
                              .Include(rr => rr.FACULTY)
                              .FirstOrDefault();
                }
            }

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