public EventS[] GetEvents()
        {
            using (MasterDBDataContext db = new MasterDBDataContext())
            {
                EventS[] result;

                var events = db.Event.ToArray();
                if (events != null)
                {
                    result = new EventS[events.Length];

                    for (int i = 0; i < events.Length; i++)
                    {
                        result[i] = new EventS()
                        {
                            id = events[i].idEvent,
                            startDate = events[i].StartDate,
                            endDate = events[i].EndDate,
                            description = events[i].Description,
                            name = events[i].Name
                        };

                        if(!String.IsNullOrEmpty(events[i].Image))
                            using (FileStream fs = new FileStream(events[i].Image, FileMode.Open, FileAccess.Read))
                        {
                            byte[] bytes = new byte[fs.Length];
                            int numBytesToRead = (int)fs.Length;
                            int numBytesRead = 0;
                            while (numBytesToRead > 0)
                            {
                                // Read may return anything from 0 to numBytesToRead.
                                int n = fs.Read(bytes, numBytesRead, numBytesToRead);

                                if (n == 0)
                                    break;

                                numBytesRead += n;
                                numBytesToRead -= n;
                            }

                            result[i].image = bytes;
                        }

                    }
                    return result;
                }
            }
            return null;
        }
        public EventS GetEvent(int id)
        {
            using (MasterDBDataContext db = new MasterDBDataContext())
            {
                Event eventGame = null;

                eventGame = db.Event.FirstOrDefault(e => e.idEvent == id);

                if (eventGame != null)
                {
                    EventS ev = new EventS()
                    {
                        id = eventGame.idEvent,
                        startDate = eventGame.StartDate,
                        endDate = eventGame.EndDate,
                        description = eventGame.Description,
                        name = eventGame.Name
                    };
                    if (!String.IsNullOrEmpty(eventGame.Image))
                        using (FileStream fs = new FileStream(eventGame.Image, FileMode.Open, FileAccess.Read))
                        {
                            byte[] bytes = new byte[fs.Length];
                            int numBytesToRead = (int)fs.Length;
                            int numBytesRead = 0;
                            while (numBytesToRead > 0)
                            {
                                // Read may return anything from 0 to numBytesToRead.
                                int n = fs.Read(bytes, numBytesRead, numBytesToRead);

                                if (n == 0)
                                    break;

                                numBytesRead += n;
                                numBytesToRead -= n;
                            }

                            ev.image = bytes;
                        }

                    return ev;
                }
            }
            return null;
        }