From 6d3d59944950b3130b5e3cefbe248a11fe15160d Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 25 Nov 2025 16:45:36 +0330 Subject: [PATCH] add DashboardController to provide client dashboard view with calendar and holiday information --- .../Client/Controllers/DashboardController.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 ServiceHost/Areas/Client/Controllers/DashboardController.cs diff --git a/ServiceHost/Areas/Client/Controllers/DashboardController.cs b/ServiceHost/Areas/Client/Controllers/DashboardController.cs new file mode 100644 index 00000000..1b722ef7 --- /dev/null +++ b/ServiceHost/Areas/Client/Controllers/DashboardController.cs @@ -0,0 +1,56 @@ +using _0_Framework.Application; +using CompanyManagment.App.Contracts.ClientDashboard; +using CompanyManagment.App.Contracts.Holiday; +using CompanyManagment.App.Contracts.HolidayItem; +using Microsoft.AspNetCore.Mvc; +using PersianTools.Core; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Client.Controllers; +public record ClientDashboardViewModel(List Calender, int Year,string Month,int Day,string DayOfWeek); + +public class DashboardController:ClientBaseController +{ + private readonly IHolidayItemApplication _holidayItemApplication; + + public DashboardController(IHolidayItemApplication holidayItemApplication) + { + _holidayItemApplication = holidayItemApplication; + } + + [HttpGet] + public ActionResult Index() + { + var calenderList = new List(); + + var todayGr = DateTime.Today; + var todayFa = todayGr.ToFarsi(); + + var todayPersian = new PersianDateTime( + int.Parse(todayFa.Substring(0, 4)), + int.Parse(todayFa.Substring(5, 2)), + int.Parse(todayFa.Substring(8, 2)) + ); + + var startDate =new PersianDateTime(todayGr.AddDays(-3)); + var endDate =new PersianDateTime(todayGr.AddDays(3)); + + + for (var day = startDate; day <= endDate; day = day.AddDays(1)) + { + var calenderNewItem = new CalenderViewModel + { + DayNumber = day.ToString("dd"), + IsToday = day.DateTime == todayGr, + DayOfWeek = day.DayOfWeek, + Holiday = _holidayItemApplication.IsHoliday(day.ToGregorianDateTime()) || day.DayOfWeek== "جمعه" + }; + calenderList.Add(calenderNewItem); + } + + + + return new ClientDashboardViewModel(calenderList, todayPersian.Year,todayPersian.MonthOfYear,todayPersian.Day,todayPersian.DayOfWeek); + } +} +