Пример #1
0
        public ResturantInfoDto GetGlobalRestaurantInfo(long restaurantId, string role, string language)
        {
            Restaurant restaurant;

            //if (role == Enums.RoleType.RestaurantAdmin.ToString())
            //{
            //    restaurant = _restaurantService.GetRestaurantByAdminId(userId);
            //    if (restaurant == null) throw new NotFoundException(ErrorCodes.RestaurantNotFound);
            //    if (restaurant.IsDeleted) throw new NotFoundException(ErrorCodes.RestaurantDeleted);
            //}
            //else
            //{
            //    var waiter = _restaurantWaiterService.Find(userId);
            //    restaurant = _restaurantService.Find(waiter.RestaurantId);
            //    if (restaurant == null) throw new NotFoundException(ErrorCodes.RestaurantNotFound);
            //    if (restaurant.IsDeleted) throw new NotFoundException(ErrorCodes.RestaurantDeleted);

            //}
            restaurant = _restaurantService.Find(restaurantId);
            var restaurantdto = new ResturantInfoDto
            {
                ResturentId    = restaurant.RestaurantId,
                BackgroundId   = restaurant.BackgroundId,
                RestaurantName = restaurant.RestaurantTranslations.FirstOrDefault(x => x.Language.ToLower() == language.ToLower()).RestaurantName,
                Rate           = _feedBackService.GetRestaurantRate(restaurantId)
            };

            return(restaurantdto);
        }
        public IHttpActionResult GetGlobalRestaurantInfo(long restaurantId)
        {
            var restaurants = _restaurantFacade.GetGlobalRestaurantInfo(restaurantId, UserRole, Language);
            //  var data = Mapper.Map<List<ResturantInfoModel>>(restaurants);
            var data = new ResturantInfoDto();

            data.LogoUrl        = Url.Link("RestaurantLogo", new { restaurantId = restaurants.ResturentId });
            data.BackgroundUrl  = Url.Link("BackgroundImage", new { restaurants.BackgroundId });
            data.RestaurantName = restaurants.RestaurantName;
            data.Rate           = restaurants.Rate;

            return(Ok(data));
        }