Esempio n. 1
0
        public List <Bookinger> GetAllBookinger()
        {
            using (SqlConnection connection = new SqlConnection(DBaddress))
            {
                var        quertstring = "SELECT * FROM Bookinger";
                SqlCommand command     = new SqlCommand(quertstring, connection);
                connection.Open();

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    int      id     = reader.GetInt32(0);
                    DateTime dato   = reader.GetDateTime(1);
                    int      userid = reader.GetInt32(2);


                    Bookinger addBookinger = new Bookinger()
                    {
                        BookingId = id, Date = dato, UserId = userid
                    };
                    BookingList.Add(addBookinger);
                }
                connection.Close();
                return(BookingList);
            }
        }
Esempio n. 2
0
        public SalViewModel(Sal sal, Bookinger bookingList)
        {
            _sal         = sal;
            _bookingList = bookingList;
            foreach (var sæde in Sal.SædeList)
            {
                sæde.Checked = false;
            }

            _valgteSæder = new List <Sæde>();
        }
Esempio n. 3
0
        public bool UpdateBookinger(Bookinger bookinger, int bookingerId)
        {
            using (SqlConnection connection = new SqlConnection(DBaddress))
            {
                var check = GetAllBookinger().Contains(bookinger);
                if (!check)
                {
                    var        querystring = $"UPDATE Bookinger SET BookingId = {bookinger.BookingId}, Date = '{bookinger.Date}', UserId = {bookinger.UserId} WHERE BookingId = {bookingerId}";
                    SqlCommand command     = new SqlCommand(querystring, connection);
                    connection.Open();

                    command.ExecuteNonQuery();
                    connection.Close();
                }

                return(check);
            }
        }
Esempio n. 4
0
        public bool CreateBookinger(Bookinger bookinger)
        {
            using (SqlConnection connection = new SqlConnection(DBaddress))
            {
                var check = GetAllBookinger().Contains(bookinger);
                if (!check)
                {
                    var querystring =
                        $"INSERT INTO Bookinger VALUES ({bookinger.BookingId},'{bookinger.Date}',{bookinger.UserId})";
                    SqlCommand command = new SqlCommand(querystring, connection);
                    connection.Open();

                    command.ExecuteNonQuery();
                    connection.Close();
                }

                return(check);
            }
        }
Esempio n. 5
0
        public Bookinger GetBookingerFromId(int bookingerId)
        {
            using (SqlConnection connection = new SqlConnection(DBaddress))
            {
                var        quertstring = $"SELECT * FROM Bookinger WHERE BookingId = {bookingerId}";
                SqlCommand command     = new SqlCommand(quertstring, connection);
                connection.Open();
                Bookinger nyBookinger = new Bookinger();

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    int      id     = reader.GetInt32(0);
                    DateTime dato   = reader.GetDateTime(1);
                    int      userid = reader.GetInt32(2);

                    nyBookinger.BookingId = id;
                    nyBookinger.Date      = dato;
                    nyBookinger.UserId    = userid;
                }
                connection.Close();
                return(nyBookinger);
            }
        }
 // PUT: api/Bookinger/5
 public void Put(int id, [FromBody] Bookinger value)
 {
     new ManageBookinger().UpdateBookinger(value, id);
 }
 // POST: api/Bookinger
 public void Post([FromBody] Bookinger value)
 {
     new ManageBookinger().CreateBookinger(value);
 }