private static void UpdatePaymentNotRecieved(EventDto eventsDto, IMyMentorRepository repository)
 {
     //payment was not recieved
     eventsDto.EventStatus = EventStatus.PaymentNotReceived;
     repository.CreateUpdateEvent(eventsDto);
 }
        private async Task<string> CreateUpdateEvent(CreateCouponViewModel couponVm, string eventStatus, IMyMentorRepository repository)
        {
            var json = new JavaScriptSerializer();
            CurrencyDto currentCurrency = null;
            var eventDto = new EventDto
            {
                ObjectId = couponVm.EventId,
                EventStatus = eventStatus,
                EventType = EventTypes.CouponPurchase,
                UserId = couponVm.TeacherData.TeacherId,
                CouponId = couponVm.CouponId,
                PaymentData = couponVm.PaymentData,
                EventData = json.Serialize(couponVm),
                PaymentAmount = couponVm.TeacherData.AmountForPayment,
                PaymentAmountNIS = ConvertToNis(couponVm.TeacherData.AmountForPayment, out currentCurrency),                
            };

            eventDto.PaymentCurrency = currentCurrency;

            return await repository.CreateUpdateEvent(eventDto);
        }
        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();
        }