private async Task <bool> RemoveMenuCurrencyByIdAsync(long menuCurrencyId) { MenuCurrencies currency = await MenuCurrencyRepo.FindById(menuCurrencyId); bool value = await RemoveItemValueByItemIdOrCurrencyId(currency.Id, isCurrencyId : true); await MenuCurrencyRepo.RemoveAsync(currency); return(value); }
private async Task <MenuCurrencies> CheckMenuCurrencyExistence(long menuCurrencyId) { MenuCurrencies menuCurrency = await MenuCurrencyRepo.FindById(menuCurrencyId); if (menuCurrency == null) { throw new Exception("Non existing entry"); } return(menuCurrency); }
public async Task <bool> RemoveMenuCurrencyAsync(long ownerId, long restaurantId, long menuCurrencyId) { CheckTheLoggedInPerson(); EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId); MenuCurrencies menuCurrency = await CheckMenuCurrencyExistence(menuCurrencyId); return(await RemoveMenuCurrencyByIdAsync(menuCurrency.Id)); }
public async Task <MenuCurrencies> UpdateMenuCurrenciesAsync(long ownerId, long restaurantId, long menuCurrencyId, long newCurrencyId) { CheckTheLoggedInPerson(); EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId); MenuCurrencies menuCurrency = await CheckMenuCurrencyExistence(menuCurrencyId); Currencies newCurrency = await CheckCurrencyExistance(newCurrencyId); menuCurrency.CurrencyId = newCurrency.Id; menuCurrency.TheCurrency = newCurrency; await MenuCurrencyRepo.UpdateAsync(menuCurrency, this.ModifierId); return(menuCurrency); }
public async Task <MenuCurrencies> AddMenuCurrencyAsync(long ownerId, long restaurantId, long currencyId) { CheckTheLoggedInPerson(); EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId); Menus currentMenu = await CheckMenuExistanceAsync(restaurantId); Currencies currencyToAdd = await CheckCurrencyExistance(currencyId); MenuCurrencies item = new MenuCurrencies { MenuId = currentMenu.Id, CurrencyId = currencyToAdd.Id }; await MenuCurrencyRepo.AddAsync(item, this.ModifierId); return(item); }