/// <summary>
        /// Metoda do konstruowania i wywoływania zapytania za pomocą sesji NHibernate
        /// </summary>
        /// <param name="session">Sesja NHibernate</param>
        public override RestaurantForm Execute(ISession session)
        {
            var restaurant = session.Get <Domain.Restaurant.Restaurant>(restaurantId);

            if (restaurant == null)
            {
                throw new TechnicalException(String.Format("Nie można znaleźć restauracji o podanym id: {0}", restaurantId));
            }

            return(RestaurantMapper.MapToForm(restaurant));
        }
        /// <summary>
        /// Metoda do konstruowania i wywoływania zapytania za pomocą sesji NHibernate
        /// </summary>
        /// <param name="session">Sesja NHibernate</param>
        public override RestaurantForm Execute(ISession session)
        {
            var restaurant = session.Get <Domain.Restaurant.Restaurant>(restaurantId);

            if (restaurant == null)
            {
                throw new TechnicalException(String.Format("You can not find a restaurant with the given id: {0}", restaurantId));
            }

            return(RestaurantMapper.MapToForm(restaurant));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Metoda do konstruowania i wywoływania zapytania za pomocą sesji NHibernate
        /// </summary>
        /// <param name="session">Sesja NHibernate</param>
        public override RestaurantForm Execute(ISession session)
        {
            var restaurantId = session
                               .CreateQuery(@"
                    select 
                        rw.Restaurant.Id
                    from RestaurantWorker rw
                    where rw.AppUser.UserId = :userId")
                               .SetInt32("userId", userId)
                               .List <System.Guid>()
                               .Single();

            var restaurant = session.Get <Domain.Restaurant.Restaurant>(restaurantId);

            return(RestaurantMapper.MapToForm(restaurant));
        }