public async Task<DeletedEntity<UserProfile>> DeteleAsync(UserProfile entity)
        {
            var userProfileToDelete = entity.Guid == Guid.Empty
                ? null
                : await UserProfiles.FindAsync(entity.Guid);
            var deletedUserProfile = userProfileToDelete == null
                ? null
                : UserProfiles.Remove(userProfileToDelete);

            await this.SaveChangesAsync();
            return new DeletedEntity<UserProfile>(deletedUserProfile);
        }
 public async Task<DeletedEntity<UserProfile>> DeteleAsync(UserProfile entity)
 {
     await Task.CompletedTask;
     return new DeletedEntity<UserProfile>(null);
 }
        public async Task<bool> AddOrUpdateAsync(UserProfile entity)
        {
            if (entity == null)
                throw new ArgumentNullException(nameof(entity));

            var existingUserProfile = entity.Guid == Guid.Empty
                ? null
                : await UserProfiles.FindAsync(entity.Guid);

            UserProfiles.AddOrUpdate(x => x.Guid, entity);

            await this.SaveChangesAsync();
            return existingUserProfile == null;
        }
 public async Task<bool> AddOrUpdateAsync(UserProfile entity)
 {
     await Task.CompletedTask;
     return false;
 }
        private async Task DeleteUserDependentEntities(UserProfile profile)
        {
            // Delete WalletAccessRights, Wallet and Transactions connected with Wallet
            var walletToDelete =
                profile.WalletAccessRights.FirstOrDefault(right => right.Permission == PermissionEnum.Owner)?.Wallet;
            var rightToDelete = walletToDelete?.WalletAccessRights.ToList();
            var transactionsToDelete = walletToDelete?.Transactions.ToList();

            var transactionsProvider = ProvidersFactory.GetNewTransactionsProviders();
            if (transactionsToDelete != null)
                foreach (var transaction in transactionsToDelete)
                {
                    await transactionsProvider.DeteleAsync(transaction);
                }

            var walletProvider = ProvidersFactory.GetNewWalletsProviders();
            if (rightToDelete != null)
                foreach (var walletAccessRight in rightToDelete)
                {
                    await walletProvider.DeteleAsync(walletAccessRight);
                }
            await walletProvider.DeteleAsync(walletToDelete);

            // Delete BudgetAccessRights and CreatedBudgets
            var budgetProvider = ProvidersFactory.GetNewBudgetsProviders();
            var userBudgets =
                profile.BudgetAccessRights
                    .Where(right => right.Permission == PermissionEnum.Owner)
                    .Select(right => right.Budget);
            foreach (var createdBudget in userBudgets)
            {
                await budgetProvider.DeteleAsync(createdBudget);
            }
        }
 /// <summary>
 ///     Creates instance of Budget from NewBudgetModel and UserProfile of creator
 /// </summary>
 /// <param name="model">NewBudgetModel instance</param>
 /// <param name="creator">Creator of the budget</param>
 /// <returns></returns>
 private Budget NewBudgetInstanceFromNewBudgetModel(NewBudgetModel model, UserProfile creator)
 {
     return new Budget
     {
         Name = model.Name,
         StartDate = model.StartDate,
         EndDate = model.EndDate,
         Limit = model.Limit,
         Description = model.Description ?? string.Empty,
         AccessRights =
             new List<BudgetAccessRight>
             {
                 new BudgetAccessRight
                 {
                     Permission = PermissionEnum.Owner,
                     UserProfile = creator
                 }
             }
     };
 }
 public Task<DeletedEntity<UserProfile>> DeteleAsync(UserProfile entity)
 {
     throw new NotImplementedException();
 }
 public Task<bool> AddOrUpdateAsync(UserProfile entity)
 {
     throw new NotImplementedException();
 }