private ParseUser[] GetTransactionUsers(TeacherData teacherData, CommissionsDto globalCommissionsTable, IMyMentorRepository repository) { var users= repository.FindUsersById(new[] { teacherData.TeacherId, teacherData.AgentId, globalCommissionsTable.MaamAccountId, globalCommissionsTable.MaamBalanceAccountId, globalCommissionsTable.SiteAccountId, }); return users; }
private static void UpdateCouponAccountStatementsAndEvent( CreateCouponViewModel createCouponVm, IMyMentorRepository repository, IEnumerable<AccountStatement> accountStatementsToUpdate, EventDto eventsDto) { var accountStatementsWithCreditOrDebit = accountStatementsToUpdate.Where(x => x.Credit > 0 || x.Debit > 0).ToArray(); var couponUpdate = ParseObject.CreateWithoutData<Coupon>(createCouponVm.CouponId); couponUpdate.CouponStatus = BL.Consts.CouponStatus.Active; // update account statements repository.BulkSave(accountStatementsWithCreditOrDebit.Union(new ParseObject[] { couponUpdate })); // set users balance foreach (var accountStatement in accountStatementsWithCreditOrDebit) { var user = Task.Run(() => repository.FindUsersById(new[] {accountStatement.User.ObjectId})).Result.SingleOrDefault(); if (user != null) { var userAdminData = user.GetPointerObject<UserAdminData>("adminData"); if (userAdminData != null) { userAdminData.Balance = accountStatement.Balance; userAdminData.BalanceNis = CurrencyConverter.ConvertToNis(accountStatement.Balance,accountStatement.Currency.ConvertToCurrencyDto(),repository); Task.Run(() => userAdminData.SaveAsync()).Wait(); } } } eventsDto.EventStatus = EventStatus.EventPaymentCompleted; Task.Run(() => repository.CreateUpdateEvent(eventsDto)).Wait(); }