private void mclDaySelect_DateSelected(object sender, DateRangeEventArgs e)
        {
            CalendarServiceReference.Calendar calendar = calendarService.Get(User.Id);//Finder kalender med bruger id
            listView.Items.Clear();

            selectedDate = e.Start;
            //Klader bookingService, og får fat i bookingerne for dagen

            IEnumerable <BookingServiceReference.Booking> bookings = new List <BookingServiceReference.Booking>();

            //Her smider vi bookinger i den.
            try
            {
                bookings = bookingService.GetAllBookingSpecificDay(calendar.Id, selectedDate);
                //presenter dem, for de er sorteret i wcf
                foreach (var booking in bookings)
                {
                    ListViewItem item = new ListViewItem();
                    string       s    = string.Format("{0} - {1}", booking.StartDate.ToShortTimeString(), booking.EndDate.ToShortTimeString());
                    string       sSub = string.Format("{0}", booking.BookingType);
                    item.Text = s;
                    item.SubItems.Add(sSub);
                    item.Tag = booking;
                    listView.Items.Add(item);
                }
            }
            catch
            {
                MessageBox.Show("Der er ikke oprettet en kalender til denne supporter. Kontakt en Administartor for at lave en kalendar", "Fejl - Ingen kalendar");
            }
        }
        private void btnCreateCal_Click(object sender, EventArgs e)
        {
            UserServiceReference.User         selectedUser = tevAllSupport.SelectedNode.Tag as UserServiceReference.User;
            CalendarServiceReference.Calendar calendar     = new CalendarServiceReference.Calendar();
            calendar.UserId = selectedUser.Id;
            calendarService.CreateCalendar(calendar);

            string s = string.Format("{0} {1}'s kalender er blevet lavet", selectedUser.FirstName, selectedUser.LastName);

            MessageBox.Show(s, "Kalender lavet");
        }
        private void btnCreateTask_Click(object sender, EventArgs e)
        {
            DateTime date;
            DateTime time;
            DateTime dateTime;

            BookingServiceReference.SupportTask supportTask = new BookingServiceReference.SupportTask();
            supportTask.User_Id = User.Id;
            date = dtpDate.Value.Date;

            time     = Convert.ToDateTime(cbTaskStatDate.Text);
            dateTime = date.Date + time.TimeOfDay;
            supportTask.StartDate = dateTime;

            time                = Convert.ToDateTime(cbTaskEndDate.Text);
            dateTime            = date.Date + time.TimeOfDay;
            supportTask.EndDate = dateTime;

            supportTask.Name        = txtTaskName.Text;
            supportTask.Description = txtTaskDescription.Text;
            CalendarServiceReference.Calendar calendar = calendarService.Get(User.Id);
            supportTask.Calendar_Id = calendar.Id;
            supportTask.BookingType = "Task";
            if (cbTaskEndDate.Text != null && cbTaskStatDate != null)
            {
                if (supportTask.EndDate > supportTask.StartDate)
                {
                    try
                    {
                        bookingService.CreateTask(supportTask);
                        this.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Kunne ikke oprette booking", "Fejl");
                    }
                }
                else
                {
                    MessageBox.Show("S**t tid er mindre end Start tid", "Fejl");
                }
            }
            else
            {
                MessageBox.Show("Ikke alle tidspunkter er udfyldt", "Fejl");
            }
        }
        //Tager den valgte dag, og sætter den ind i selectedDate
        private void mclDaySelect_DateSelected(object sender, DateRangeEventArgs e)
        {
            listView.Items.Clear();
            int  userId;
            bool result = Int32.TryParse(txtUserId.Text, out userId);


            CalendarServiceReference.Calendar calendar = calendarService.Get(userId); //Finder kalender med bruger id
            selectedDate = e.Start;
            if (result && txtUserId.Text != null)
            {
                //Klader bookingService, og får fat i bookingerne for dagen

                IEnumerable <BookingServiceReference.Booking> bookings = new List <BookingServiceReference.Booking>();
                try
                {
                    //Her smider vi bookinger i den.
                    bookings = bookingService.GetAllBookingSpecificDay(calendar.Id, selectedDate);
                    //presenter dem, for de er sorteret i wcf
                    foreach (var booking in bookings)
                    {
                        ListViewItem item = new ListViewItem();
                        string       s    = string.Format("{0} - {1}", booking.StartDate.ToShortTimeString(), booking.EndDate.ToShortTimeString());
                        string       sSub = string.Format("{0}", booking.BookingType);
                        item.Text = s;
                        item.SubItems.Add(sSub);
                        item.Tag = booking;
                        listView.Items.Add(item);
                    }
                }
                catch
                {
                    MessageBox.Show("Der er ikke oprettet en kalender til denne supporter. Lave en kalendar til givende bruger", "Fejl - Ingen kalendar");
                }
            }
            else
            {
                string s = string.Format("{0} er ikke et nummer", txtUserId.Text);
                MessageBox.Show(s, "Fejl");
            }
        }
 //Tager mod en user fra gui, og sender den op til wcf'en
 public void CreateCalendar(CalendarServiceReference.Calendar calendar)
 {
     calendarService.Create(calendar);
 }