コード例 #1
0
 /// <summary>
 /// Creates a new instance for diplaying a month.
 /// </summary>
 /// <param name="categoryKey">A category key or empty key.</param>
 public OverviewParameter(IKey categoryKey, MonthModel month)
 {
     Ensure.NotNull(categoryKey, "categoryKey");
     Ensure.NotNull(month, "month");
     CategoryKey = categoryKey;
     Month       = month;
 }
コード例 #2
0
    private void GetTopTransaction()
    {
        Transaction             clsTransaction = new Transaction();
        List <TransactionModel> lstTransaction = new List <TransactionModel>();
        HashSet <string>        selectedMonths = new HashSet <string>();
        MonthModel mdlMonth = new MonthModel();

        lstTransaction = clsTransaction.GetByMonth(int.Parse(Session["User_Id"].ToString()), -6, 1);

        foreach (TransactionModel mdlTransaction in lstTransaction)
        {
            selectedMonths.Add(mdlTransaction.DateCreated.ToString("MMM"));
        }

        foreach (string item in selectedMonths)
        {
            mdlMonth = new MonthModel
            {
                Month  = item,
                Amount = 0
            };
            lstMonth.Add(mdlMonth);
        }

        foreach (TransactionModel mdlTransaction in lstTransaction)
        {
            lstMonth.Where(w => w.Month == mdlTransaction.DateCreated.ToString("MMM")).ToList().ForEach(s => s.Amount = (s.Amount + mdlTransaction.Amount));
        }
    }
コード例 #3
0
        public async Task <List <MonthWithAmountModel> > HandleAsync(ListMonthOutcomesForCategory query)
        {
            using (ReadModelContext db = dbFactory.Create())
            {
                var sql = db.Outcomes
                          .WhereUserKey(query.UserKey)
                          .Where(o => o.When.Year == query.Year.Year);

                sql = ApplyCategoryKey(sql, query.CategoryKey);

                List <OutcomeEntity> entities = await sql.ToListAsync();

                Dictionary <MonthModel, Price> totals = new Dictionary <MonthModel, Price>();
                foreach (OutcomeEntity entity in entities)
                {
                    MonthModel month = entity.When;
                    Price      price;
                    if (totals.TryGetValue(month, out price))
                    {
                        price = price + priceConverter.ToDefault(query.UserKey, entity);
                    }
                    else
                    {
                        price = priceConverter.ToDefault(query.UserKey, entity);
                    }

                    totals[month] = price;
                }

                return(totals
                       .Select(t => new MonthWithAmountModel(t.Key.Year, t.Key.Month, t.Value))
                       .ToList());
            }
        }
コード例 #4
0
        private async Task <Dictionary <MonthModel, Price> > GetMonthBalanceIncomesAsync(ReadModelContext db, ListMonthBalance query)
        {
            var sql = db.Incomes
                      .WhereUserKey(query.UserKey)
                      .Where(o => o.When.Year == query.Year.Year);

            List <IncomeEntity> entities = await sql.ToListAsync();

            Dictionary <MonthModel, Price> totals = new Dictionary <MonthModel, Price>();

            foreach (IncomeEntity entity in entities)
            {
                MonthModel month = entity.When;
                Price      price;
                if (totals.TryGetValue(month, out price))
                {
                    price = price + priceConverter.ToDefault(query.UserKey, entity);
                }
                else
                {
                    price = priceConverter.ToDefault(query.UserKey, entity);
                }

                totals[month] = price;
            }

            return(totals);
        }
コード例 #5
0
 public ListMonthIncome(MonthModel month, SortDescriptor <IncomeOverviewSortType> sortDescriptor = null, int?pageIndex = null)
 {
     Ensure.NotNull(month, "month");
     Month          = month;
     SortDescriptor = sortDescriptor;
     PageIndex      = pageIndex;
 }
コード例 #6
0
        private async Task LoadMonthViewAsync(GroupViewModel viewModel, MonthModel prefered)
        {
            ViewModel.IsLoading = true;

            IEnumerable <MonthModel> months = await queryDispatcher.QueryAsync(new ListMonthWithOutcome());

            int?preferedIndex = null;
            int index         = 0;

            foreach (MonthModel month in months)
            {
                viewModel.Add(month.ToString(), month);

                if (prefered == month)
                {
                    preferedIndex = index;
                }

                index++;
            }

            if (preferedIndex != null)
            {
                pvtGroups.SelectedIndex = preferedIndex.Value;
            }

            ViewModel.IsLoading = false;
        }
コード例 #7
0
        public Task HandleAsync(OutcomeCreated payload)
        {
            bool isReloadRequired = false;

            if (parameter.Month != null)
            {
                MonthModel other = payload.When;
                if (!ViewModel.Items.Any(g => g.Parameter.Equals(other)))
                {
                    isReloadRequired = true;
                }
            }
            else if (parameter.Year != null)
            {
                YearModel other = new YearModel(payload.When.Year);
                if (!ViewModel.Items.Any(g => g.Parameter.Equals(other)))
                {
                    isReloadRequired = true;
                }
            }
            else
            {
                if (!ViewModel.Items.Any())
                {
                    isReloadRequired = true;
                }
            }

            if (isReloadRequired)
            {
                ReloadAsync();
            }

            return(Task.CompletedTask);
        }
コード例 #8
0
 public void AddMonth(MonthModel month)
 {
     if (!Months.ContainsKey(month.Id))
     {
         this.Months.Add(month.Id, month);
     }
 }
コード例 #9
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="categoryKey">A key of the category.</param>
 /// <param name="month">A month to find outcomes from.</param>
 public ListMonthOutcomeFromCategory(IKey categoryKey, MonthModel month)
 {
     Ensure.NotNull(categoryKey, "categoryKey");
     Ensure.NotNull(month, "month");
     CategoryKey = categoryKey;
     Month       = month;
 }
コード例 #10
0
        Task IEventHandler <OutcomeWhenChanged> .HandleAsync(OutcomeWhenChanged payload)
        {
            OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key));

            if (viewModel != null)
            {
                viewModel.When = payload.When;
                if (Period is MonthModel month)
                {
                    MonthModel newValue = payload.When;
                    if (month != newValue)
                    {
                        Items.Remove(viewModel);
                    }
                }
                else if (Period is YearModel year)
                {
                    YearModel newValue = new YearModel(payload.When.Year);
                    if (year != newValue)
                    {
                        Items.Remove(viewModel);
                    }
                }
            }

            return(Task.CompletedTask);
        }
コード例 #11
0
ファイル: MonthView.cs プロジェクト: magierska/Calendar
 public MonthView(TableLayoutPanel _bigPanel, Label _title, DayManager _dayManager)
 {
     bigPanel   = _bigPanel;
     title      = _title;
     dayManager = _dayManager;
     model      = new MonthModel();
 }
コード例 #12
0
        protected async void OnMonthSelected(MonthModel selectedMonth)
        {
            SelectedMonth = selectedMonth;
            await LoadMonthSummaryAsync();

            StateHasChanged();
        }
コード例 #13
0
        public void Six_Weeks_of_month_of_2019_09_08()
        {
            var calendar = new MonthModel(new CultureInfo("de-DE"), new LocalDate(2019, 9, 8));

            var weeks = calendar.Weeks.ToArray();

            weeks.Length.Should().Be(6);
        }
コード例 #14
0
        public void Four_Weeks_of_month_of_2010_02_08()
        {
            var calendar = new MonthModel(new CultureInfo("de-DE"), new LocalDate(2010, 2, 8));

            var weeks = calendar.Weeks.ToArray();

            weeks.Length.Should().Be(4);
        }
コード例 #15
0
        public ActionResult Load(int year, int month)
        {
            var model = new MonthModel(year, month);

            return(Request.IsAjaxRequest()
        ? PartialView("_Month", model)
        : (ActionResult)View("_Month", model));
        }
コード例 #16
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="categoryKey">A key of the category.</param>
 /// <param name="month">A month to find outcomes from.</param>
 /// <param name="sortDescriptor">A sorting descriptor.</param>
 /// <param name="pageIndex">A page index to load. If <c>null</c>, load all results.</param>
 public ListMonthOutcomeFromCategory(IKey categoryKey, MonthModel month, SortDescriptor <OutcomeOverviewSortType> sortDescriptor = null, int?pageIndex = null)
 {
     Ensure.NotNull(categoryKey, "categoryKey");
     Ensure.NotNull(month, "month");
     CategoryKey    = categoryKey;
     Month          = month;
     SortDescriptor = sortDescriptor;
     PageIndex      = pageIndex;
 }
コード例 #17
0
ファイル: MonthModelTest.cs プロジェクト: magierska/Calendar
        public void MonthGetPreviousDays()
        {
            MonthModel model = new MonthModel();

            model.GenerateDays(new Day(new DateTime(2017, 11, 11)));
            Day nextDay = model.GetPreviousDay();

            Assert.AreEqual(10, nextDay.Month);
        }
コード例 #18
0
ファイル: MonthModelTest.cs プロジェクト: magierska/Calendar
        public void MonthGenerateDaysTest()
        {
            MonthModel model = new MonthModel();

            model.GenerateDays(new Day(new DateTime(2017, 11, 11)));
            Assert.IsTrue(model.Days[0][0].DateEquals(new Day(new DateTime(2017, 10, 30))));
            Assert.IsTrue(model.Days.Count == 5);
            Assert.IsTrue(model.Days[4][6].DateEquals(new Day(new DateTime(2017, 12, 3))));
        }
コード例 #19
0
 public NotEmptyMonthCategoryGroupProvider(IQueryDispatcher queryDispatcher, IFactory <Price, decimal> priceFactory, MonthModel month)
 {
     Ensure.NotNull(queryDispatcher, "queryDispatcher");
     Ensure.NotNull(priceFactory, "priceFactory");
     Ensure.NotNull(month, "month");
     this.queryDispatcher = queryDispatcher;
     this.priceFactory    = priceFactory;
     this.month           = month;
 }
コード例 #20
0
 public static Month Map(MonthModel objModel)
 {
     return(new Month
     {
         Id = objModel.Id,
         LanguageId = objModel.LanguageId,
         MonthName = objModel.Month
     });
 }
コード例 #21
0
        private void contextMenuDeleteMonth_Click(object sender, EventArgs e)
        {
            MonthModel selectedMonth = this.GetSelectedMonth()?.Model;

            if (selectedMonth != null)
            {
                modelController.RemoveMonth(selectedMonth.Id);
                RefreshView();
            }
        }
コード例 #22
0
        private void SetLimit(decimal value, Action <MonthModel, decimal> set)
        {
            MonthModel selectedMonth = this.GetSelectedMonth()?.Model;

            if (selectedMonth != null)
            {
                set(selectedMonth, value);
                RefreshView();
            }
        }
コード例 #23
0
        protected override async Task OnInitializedAsync()
        {
            PagingContext = new PagingContext(LoadDataAsync, Loading);

            BindEvents();

            MonthModel = new MonthModel(Year, Month);

            CurrencyFormatter = new CurrencyFormatter(await Queries.QueryAsync(new ListAllCurrency()));
            Reload();
        }
コード例 #24
0
        private void contextMenuDelete_Click(object sender, EventArgs e)
        {
            Expense    selectedExpense = GetSelectedExpense()?.Model;
            MonthModel selectedMonth   = this.GetSelectedMonth()?.Model;

            if (selectedMonth != null && selectedExpense != null)
            {
                modelController.RemoveExpense(selectedMonth.Id, selectedExpense);
                RefreshView();
            }
        }
コード例 #25
0
 public string UrlOverview(MonthModel month, IKey categoryKey)
 {
     if (categoryKey.IsEmpty)
     {
         return(UrlOverview(month));
     }
     else
     {
         return($"/{month.Year}/{month.Month}/overview/{categoryKey.AsGuidKey().Guid}");
     }
 }
コード例 #26
0
        Task IEventHandler <OutcomeCreated> .HandleAsync(OutcomeCreated payload)
        {
            MonthModel payloadMonth = payload.When;

            if (MonthModel == payloadMonth)
            {
                Reload();
            }

            return(Task.CompletedTask);
        }
コード例 #27
0
        private void AddMonthInner(MonthModel model)
        {
            if (!Months.ContainsKey(model.Id))
            {
                Settings settings = settingsController.Settings;

                model.ContinuosExpenseMax = settings.MonthContinuosExpenseMax;
                model.ExpenseMax          = settings.MonthExpenseMax;

                this.Months[model.Id] = model;
            }
        }
コード例 #28
0
        public void Correct_Weeks_of_month_of_2019_04_08()
        {
            var calendar = new MonthModel(new CultureInfo("de-DE"), new LocalDate(2019, 4, 8));

            var weeks = calendar.Weeks.ToArray();

            weeks[0].Days.First().Day.Should().Be(1);
            weeks[1].Days.First().Day.Should().Be(8);
            weeks[2].Days.First().Day.Should().Be(15);
            weeks[3].Days.First().Day.Should().Be(22);
            weeks[4].Days.First().Day.Should().Be(29);
        }
コード例 #29
0
        protected override async Task OnInitializedAsync()
        {
            PagingContext = new PagingContext(LoadDataAsync, Loading);

            BindEvents();

            MonthModel = new MonthModel(Year, Month);

            CurrencyFormatter = await CurrencyFormatterFactory.CreateAsync();

            Reload();
        }
コード例 #30
0
        protected async Task LoadMonthsAsync(MonthModel selected = null)
        {
            Months = await Queries.QueryAsync(new ListMonthWithOutcome());

            if (selected != null)
            {
                OnMonthSelected(selected);
            }
            else if (SelectedMonth == null)
            {
                OnMonthSelected(Months.FirstOrDefault());
            }
        }