public void Update(int id, Restaurant restaurant)
        {
            Restaurant rest;

            rest = _context.Restaurants.FirstOrDefault(r => r.Id == id);
            rest = restaurant;

            _context.Update(rest);
            _context.SaveChanges();
        }
Example #2
0
        public async Task <TEntity> UpdateAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }

            try
            {
                _repositoryFoodDbContext.Update(entity);
                await _repositoryFoodDbContext.SaveChangesAsync();

                return(entity);
            }
            catch (Exception)
            {
                throw new Exception($"{nameof(entity)} could not be updated");
            }
        }