public Food_AccountFoodFavoriteDTO(AccountFoodFavorite AccountFoodFavorite) { this.AccountId = AccountFoodFavorite.AccountId; this.FoodId = AccountFoodFavorite.FoodId; this.Food = AccountFoodFavorite.Food == null ? null : new Food_FoodDTO(AccountFoodFavorite.Food); this.Errors = AccountFoodFavorite.Errors; }
public async Task <Account> LikeFood(Account Account) { try { var oldData = await UOW.AccountRepository.Get(Account.Id); oldData.AccountFoodFavorites = new List <AccountFoodFavorite>(); if (Account.AccountFoodFavorites != null) { foreach (var AccountFoodFavorite in Account.AccountFoodFavorites) { AccountFoodFavorite accountFoodFavorite = new AccountFoodFavorite { AccountId = Account.Id, FoodId = AccountFoodFavorite.FoodId }; oldData.AccountFoodFavorites.Add(accountFoodFavorite); } } await UOW.Begin(); await UOW.AccountRepository.Update(oldData); await UOW.Commit(); return(oldData); } catch (Exception ex) { await UOW.Rollback(); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
private async Task SaveReference(AccountFoodFavorite AccountFoodFavorite) { }
public Account_AccountFoodFavoriteDTO(AccountFoodFavorite AccountFoodFavorite) { this.AccountId = AccountFoodFavorite.AccountId; this.FoodId = AccountFoodFavorite.FoodId; this.Errors = AccountFoodFavorite.Errors; }