public Reservation CreateAReservation(Reservation newReservation)
        {
            //A reservation creation is always defined by the state call to confirm to the seller.
            newReservation.State = new ReservationState() { Name = ReservationState.State.CallintoConfirm.Value() };
            var result = _reservations.Collection.Insert(newReservation);
            if (result.Ok)
                return newReservation;

            return null;
        }
        public ActionResult Reserve(string date, string hour, string dishId)
        {
            //safe datetime parsing
            DateTime givenDate;
            DateTime givenHour;
            DateTime.TryParse(date, out givenDate);
            DateTime.TryParse(hour, out givenHour);

            //If wrong date or hour, return to the page.
            if (givenDate == null || givenHour == null)
            {
                return RedirectToAction("Show", "Dish", new { dishid = dishId });
            }

            var User = UserContext.Current.CurrentUser;
            var dish = DishSvc.GetDishById(dishId);

            //If the user is the sqme thqn the dish, returns to Dish/Show notifying the error.
            if (User.id == dish.Seller._id.ToString())
            {
                UserContext.Current.Notify = "Error! You cannot reserve your own dish!";
                UserContext.Current.NotifyType = notificationType.error.Value();
                return RedirectToAction("Show", "Dish", new { dishid = dishId });
            }

            // new reservation
                var newReservation = new Reservation()
                {
                    Buyer = new NestedUser() { _id = ObjectId.Parse(User.id), Email = User.Email, Username = User.Username },
                    Date = givenDate,
                    Hour = givenHour,
                    LinkedDish = dish
                };

            // The call to confirm state is setted within the service.
                ReservationSvc.CreateAReservation(newReservation);

            //notification
                UserContext.Current.Notify = "Reservation done! Check out reservation category.";
                UserContext.Current.NotifyType = notificationType.success.Value();

                return RedirectToAction("Index", "Account");
        }
 //Update done on the reservation id of the given reservation.
 public Reservation UpdateReservation(Reservation reservation)
 {
     var query = Query.EQ("_id", reservation._id);
     _reservations.Collection.Update(query, Update.Replace<Reservation>(reservation));
     return reservation;
 }