/// <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; }
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)); } }
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()); } }
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); }
public ListMonthIncome(MonthModel month, SortDescriptor <IncomeOverviewSortType> sortDescriptor = null, int?pageIndex = null) { Ensure.NotNull(month, "month"); Month = month; SortDescriptor = sortDescriptor; PageIndex = pageIndex; }
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; }
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); }
public void AddMonth(MonthModel month) { if (!Months.ContainsKey(month.Id)) { this.Months.Add(month.Id, month); } }
/// <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; }
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); }
public MonthView(TableLayoutPanel _bigPanel, Label _title, DayManager _dayManager) { bigPanel = _bigPanel; title = _title; dayManager = _dayManager; model = new MonthModel(); }
protected async void OnMonthSelected(MonthModel selectedMonth) { SelectedMonth = selectedMonth; await LoadMonthSummaryAsync(); StateHasChanged(); }
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); }
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); }
public ActionResult Load(int year, int month) { var model = new MonthModel(year, month); return(Request.IsAjaxRequest() ? PartialView("_Month", model) : (ActionResult)View("_Month", model)); }
/// <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; }
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); }
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)))); }
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; }
public static Month Map(MonthModel objModel) { return(new Month { Id = objModel.Id, LanguageId = objModel.LanguageId, MonthName = objModel.Month }); }
private void contextMenuDeleteMonth_Click(object sender, EventArgs e) { MonthModel selectedMonth = this.GetSelectedMonth()?.Model; if (selectedMonth != null) { modelController.RemoveMonth(selectedMonth.Id); RefreshView(); } }
private void SetLimit(decimal value, Action <MonthModel, decimal> set) { MonthModel selectedMonth = this.GetSelectedMonth()?.Model; if (selectedMonth != null) { set(selectedMonth, value); RefreshView(); } }
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(); }
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(); } }
public string UrlOverview(MonthModel month, IKey categoryKey) { if (categoryKey.IsEmpty) { return(UrlOverview(month)); } else { return($"/{month.Year}/{month.Month}/overview/{categoryKey.AsGuidKey().Guid}"); } }
Task IEventHandler <OutcomeCreated> .HandleAsync(OutcomeCreated payload) { MonthModel payloadMonth = payload.When; if (MonthModel == payloadMonth) { Reload(); } return(Task.CompletedTask); }
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; } }
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); }
protected override async Task OnInitializedAsync() { PagingContext = new PagingContext(LoadDataAsync, Loading); BindEvents(); MonthModel = new MonthModel(Year, Month); CurrencyFormatter = await CurrencyFormatterFactory.CreateAsync(); Reload(); }
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()); } }