public async Task <RestaurantBranch> Add(RestaurantBranch model)
        {
            var entity = _restaurantBranchRepository.Add(model);
            await _restaurantBranchRepository.SaveChangeAsync();

            return(model);
        }
        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);
        }
        public IActionResult Edit([FromBody] RestaurantBranch m)
        {
            //RestaurantBranch m1 = _context.RestaurantBranch.Where(s => s.BranchId == m.BranchId).FirstOrDefault();

            _context.Update(m);
            _context.SaveChanges();
            return(RedirectToAction(nameof(Get)));
        }
        public async Task <bool> Put(RestaurantBranch model)
        {
            var result = false;

            if (ModelState.IsValid)
            {
                result = await _restaurantBranchBusiness.Update(model);
            }
            return(result);
        }
        public async Task <bool> Update(RestaurantBranch model)
        {
            var result = false;
            var record = await _restaurantBranchRepository.Repo.FirstOrDefaultAsync(c => c.Id == model.Id);

            if (record != null)
            {
                record.Name      = model.Name;
                record.StateId   = model.StateId;
                record.CityId    = model.CityId;
                record.Zip       = model.Zip;
                record.Address   = model.Address;
                record.Phone     = model.Phone;
                record.OpenTime  = model.OpenTime;
                record.CloseTime = model.CloseTime;
                record.AllDay    = model.AllDay;

                await _restaurantBranchRepository.SaveChangeAsync();

                result = true;
            }
            return(result);
        }
 public IActionResult Create([FromBody] RestaurantBranch c)
 {
     _context.Add(c);
     _context.SaveChanges();
     return(RedirectToAction(nameof(Get)));
 }