コード例 #1
0
        public async Task <IActionResult> PutRecurrentMoneyItem(long id, RecurrentMoneyItem recurrentMoneyItem)
        {
            if (id != recurrentMoneyItem.ID)
            {
                return(BadRequest());
            }

            _context.Entry(recurrentMoneyItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecurrentMoneyItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        async Task ViewChild(RecurrentMoneyItem item)
        {
            var res = await dialogService.OpenAsync <RecurrentItems>($"Associated Items",
                                                                     new Dictionary <string, object>() { { "parentItemID", item.ID } },
                                                                     new DialogOptions()
            {
                Width = "800px", Height = "600px"
            });

            await InitializeList();

            StateHasChanged();
        }
コード例 #3
0
        private static DateTime CalculateActualInstallmentDate(RecurrentMoneyItem item, DateTime currentInstallmentOriginal)
        {
            DateTime currentInstallmentDate;
            var      adjustment = item.Adjustements?.Where(x => x.RecurrencyDate == currentInstallmentOriginal && x.RecurrencyNewDate.HasValue).FirstOrDefault();

            if (adjustment != null)
            {
                currentInstallmentDate = adjustment.RecurrencyNewDate.Value;
            }
            else
            {
                currentInstallmentDate = currentInstallmentOriginal;
            }
            return(currentInstallmentDate);
        }
コード例 #4
0
        async Task Edit(RecurrentMoneyItem item)
        {
            bool?res = await dialogService.OpenAsync <RecurrentItemEdit>($"Edit item",
                                                                         new Dictionary <string, object>() { { "recurrentItemToEdit", item }, { "isNew", false }, { "parentItemID", parentItemID } },
                                                                         new DialogOptions()
            {
                Width = "600px"
            });

            if (res.HasValue && res.Value)
            {
                await InitializeList();

                StateHasChanged();
            }
        }
コード例 #5
0
        public async Task <ActionResult <RecurrentMoneyItem> > PostRecurrentMoneyItem(RecurrentMoneyItem recurrentMoneyItem)
        {
            _context.RecurrentMoneyItems.Add(recurrentMoneyItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRecurrentMoneyItem", new { id = recurrentMoneyItem.ID }, recurrentMoneyItem));
        }
コード例 #6
0
        IEnumerable <(DateTime original, DateTime currentDate)> CalculateInstallmentInPeriod(RecurrentMoneyItem item, DateTime periodStart, DateTime periodEnd)
        {
            var lstInstallmentsDate = new List <(DateTime original, DateTime currentDate)>();

            if (item.StartDate <= periodEnd && periodStart <= item.EndDate)
            {
                var currentInstallmentOriginal = item.StartDate;
                var currentInstallmentDate     = CalculateActualInstallmentDate(item, currentInstallmentOriginal);
                while (currentInstallmentDate <= periodEnd)
                {
                    if (currentInstallmentDate >= periodStart)
                    {
                        lstInstallmentsDate.Add((currentInstallmentOriginal, currentInstallmentDate));
                    }
                    if (item.RecurrencyInterval == 0)
                    {
                        break;
                    }
                    currentInstallmentOriginal = CalculateNextReccurrency(currentInstallmentOriginal, item.RecurrencyType, item.RecurrencyInterval);
                    currentInstallmentDate     = CalculateActualInstallmentDate(item, currentInstallmentOriginal);
                }
            }
            return(lstInstallmentsDate);
        }