Esempio n. 1
0
        public async Task <IEnumerable <Reminder> > CreateAsync(int companyId, int loginUserId, int useForeignCurrency, Reminder[] Reminder, ReminderCommonSetting setting, ReminderSummarySetting[] summary, CancellationToken token = default(CancellationToken))
        {
            using (var scope = transactionScopeBuilder.Create())
            {
                //var commonSetting = getReminderCommonSettingQueryProcessor.GetItems(companyId);
                //if (commonSetting == null || !commonSetting.First().Equals(setting))
                //    return null;

                //var summarySetting = reminderSummarySettingQueryProcessor.GetItems(companyId, useForeignCurrency);
                //if (summarySetting == null || !summarySetting.ToArray().Equals(summary))
                //    return null;

                var defaultStatusId = (await statusQueryProcessor.GetAsync(new StatusSearch {
                    CompanyId = companyId, StatusType = 1, Codes = new[] { "00" }
                }, token)).First().Id;

                var result = new List <Reminder>();
                foreach (var r in Reminder)
                {
                    r.StatusId = defaultStatusId;
                    var reminderEntity = await addReminderQueryProcessor.AddAsync(r, token);

                    r.Id = reminderEntity.Id;

                    var reminderSummary = new ReminderSummary()
                    {
                        CustomerId = r.CustomerId,
                        CurrencyId = r.CurrencyId,
                        Memo       = "",
                    };
                    await addReminderQueryProcessor.AddSummaryAsync(reminderSummary, token);

                    var billingUpdateResult = (await updateBillingReminderQueryProcessor.UpdateAsync(r, setting, summary)).ToArray();

                    if (r.DetailCount != billingUpdateResult.Length || r.RemainAmount != billingUpdateResult.Sum(x => x.RemainAmount))
                    {
                        return(null);
                    }

                    result.Add(reminderEntity);
                }
                scope.Complete();

                return(result.ToArray());
            }
        }
Esempio n. 2
0
 public async Task <IEnumerable <Status> > GetAsync(StatusSearch option, CancellationToken token = default(CancellationToken))
 => await statusQueryProcessor.GetAsync(option, token);