public async Task UnBook_AuthorizedUser_BookNotFound_ExpectedResult()
        {
            _uut.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim("LaundryUser", "IsLaundryUser")
                    }))
                }
            };
            BookingSeeder bs = new BookingSeeder();

            bs.CreateNewBookList(_context, bs.CreateDateModel(_context, "2021-05-21"));
            int  Id      = 1; // første object i bookingList
            int  Id2     = 2;
            long Id3     = 3;
            var  booking = await _context.BookingListModels.Include(b => b.Machine).FirstOrDefaultAsync(b => b.Id == Id);

            var booking2 = await _context.BookingListModels.Include(b => b.Machine).FirstOrDefaultAsync(b => b.Id == Id2);

            await _uut.Book(Id);

            await _uut.Book(Id2);

            var res = _uut.Unbook(Id3);
            var tmp = res.Result;


            Assert.IsType <NotFoundResult>(tmp);


            Dispose();
        }
        public async Task UnBook_AuthorizedUser_ExpectedHTTPdResult()
        {
            _uut.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim("LaundryUser", "IsLaundryUser")
                    }))
                }
            };

            long          Id = 1; // første object i bookingList
            BookingSeeder bs = new BookingSeeder();

            bs.CreateNewBookList(_context, bs.CreateDateModel(_context, "2021-05-21"));
            var booking = await _context.BookingListModels.Include(b => b.Machine).FirstOrDefaultAsync(b => b.Id == Id);

            var res = await _uut.Book(Id);

            Assert.Equal((int)HttpStatusCode.OK, _uut.ControllerContext.HttpContext.Response.StatusCode);

            Dispose();
        }
        public async Task UnBook_AuthorizedUser_ExpectedDatabaseResult()
        {
            _uut.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim("LaundryUser", "IsLaundryUser")
                    }))
                }
            };
            BookingSeeder bs = new BookingSeeder();

            bs.CreateNewBookList(_context, bs.CreateDateModel(_context, "2021-05-21"));
            int Id      = 1; // første object i bookingList
            int Id2     = 2;
            var booking = await _context.BookingListModels.Include(b => b.Machine).FirstOrDefaultAsync(b => b.Id == Id);

            var booking2 = await _context.BookingListModels.Include(b => b.Machine).FirstOrDefaultAsync(b => b.Id == Id2);

            await _uut.Book(Id);

            await _uut.Book(Id2);

            await _uut.Unbook(Id);

            var reserved = await _context.ReservedListModels.Include(b => b.Machine)
                           .FirstOrDefaultAsync(r => r.OldId == Id);

            Assert.Null(reserved);
            Dispose();
        }
        public async Task Book_AuthorizedUser_BookNotFound_ExpectedResult()
        {
            _uut.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
                    {
                        new Claim("LaundryUser", "IsLaundryUser")
                    }))
                }
            };
            BookingSeeder bs = new BookingSeeder();

            bs.CreateNewBookList(_context, bs.CreateDateModel(_context, "2021-05-21"));
            var bookinglist = _context.BookingListModels.ToList();


            int Id = bookinglist.Count + 1; // Sikre at skaffe et id et større end antal bookings i databasen

            var res = _uut.Book(Id);
            var tmp = res.Result;


            Assert.IsType <NotFoundResult>(tmp);


            Dispose();
        }
        public async Task <IActionResult> AvailableBookings(DateViewModel obj)
        {
            if (User.HasClaim("LaundryUser", "IsLaundryUser"))
            {
                //obj.Datedata = DateTime.Parse("22-04-2021");
                var bookingList = await _dataAccess.BookingList.GetAllAvalableBookings(obj.Datedata);

                if (bookingList.Count == 0)
                {
                    BookingSeeder bs        = new BookingSeeder();
                    var           datemodel = bs.CreateDateModel(_context, obj.Datedata.Date.ToString());
                    bs.CreateNewBookList(_context, datemodel);
                }
                bookingList = await _dataAccess.BookingList.GetAllAvalableBookings(obj.Datedata);

                List <BookingListViewModel> modelList = new List <BookingListViewModel>();

                foreach (var booking in bookingList)
                {
                    if (booking.Status)
                    {
                        BookingListViewModel model = new BookingListViewModel();
                        model.BookingID   = booking.Id;
                        model.Date        = booking.Date;
                        model.MachineName = booking.Machine.MachineId;
                        model.MachineType = booking.Machine.Type;
                        model.Time        = booking.Time;

                        modelList.Add(model);
                    }
                }
                modelList.Sort((res1, res2) => res1.MachineName.CompareTo(res2.MachineName));
                return(View(modelList));
            }

            return(Unauthorized());
        }