// GET: ReservationView
        public ActionResult Index()
        {
            var model = new ReservationView();
            using (var db = new WasherContext())
            {

                model.ViewReservation = db.Reservation
                    .Include(x => x.Reservationlist)
                    .FirstOrDefault(x => x.Id == "2016-01-01 08");
                model.ViewResidents = db.Residents.ToList();
                model.selectResidentsList = new SelectList(db.Residents.ToList(), "ResidentId", "Name");
                ViewBag.Title = "Bokning";

            }
            return View(model);
        }
        // GET: Reservations/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var model = new ReservationView();
            using (var db = new WasherContext())
            {
                
                model.ViewReservation = db.Reservation
                    .Include(x => x.Reservationlist)
                    .FirstOrDefault(x => x.Id == id);
                model.ViewResidents = db.Residents.ToList();
                model.selectResidentsList = new SelectList(db.Residents.ToList(), "ResidentId", "Name");
                ViewBag.Title = "Bokning";

            }
            return View(model);
        }
 public ActionResult QueReservation(ReservationView rw)
 {
   var result = MakeQueReservation( rw.selectedResidentId, rw.ViewReservation.Id,rw.ViewReservation.RowVersion);
     return result.Succes ? RedirectToAction("Index") : RedirectToAction("Index");
 }
        public ActionResult Edit( ReservationView reservation)
        {
            var result = MakeReservation(
                reservation.selectedResidentId, reservation.ViewReservation.Id, reservation.ViewReservation.RowVersion);

            if (!result.Succes)
            {
                return RedirectToAction("Index");
            }
            return RedirectToAction("Index");
            
        }