public async Task <int> Post(RestaurantBranch model)
        {
            var result = 0;

            if (ModelState.IsValid)
            {
                //check Restaurant Type
                var restaurant = await _restaurantBusiness.GetById(_authenticationDto.RestaurantId);

                if (restaurant != null && restaurant.TypeId == (int)ERestaurantType.Online)
                {
                    //if Online Restaurant had 1 Branch before, can not add more
                    // check count of Branch
                    var branch = await _restaurantBranchBusiness.GetAll(_authenticationDto.RestaurantId, 0, 10);

                    if (branch.TotalItems > 0)
                    {
                        return(result);
                    }
                }

                model.Status = 1;
                var modelInsert = await _restaurantBranchBusiness.Add(model);

                result = modelInsert.Id;
            }
            return(result);
        }
Пример #2
0
 public async Task <RestaurantDto> Get(int id)
 {
     return(await _restaurantBusiness.GetById(id));
 }