Exemplo n.º 1
0
        public static DisplayPeriod ConvertPeriodNumberDateJsonToDisplayPeriod(PeriodNumberDateJson json, IUnitOfWork uow, User currUser)
        {
            DisplayPeriodManager dpm         = new DisplayPeriodManager(uow);
            UserManager          userManager = new UserManager(uow);
            DisplayPeriod        result      = new DisplayPeriod();

            result           = dpm.GetDisplayPeriod(currUser);
            result.IsWeekly  = json.IsWeekly;
            result.NumOfDays = json.Days;
            result.StartDate = DateUtility.GetMiladiDate(json.Date);
            return(result);
        }
Exemplo n.º 2
0
        public IActionResult ChangeDisplayPeriodToDaily(PeriodNumberDateJson period)
        {
            try
            {
                var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName);
                DisplayPeriodManager displayPeriodMnager = new DisplayPeriodManager(this._uow);
                var displayPeriod = DisplayPeriodUtilities.ConvertPeriodNumberDateJsonToDisplayPeriod(period, this._uow, currentUser);
                //SyncWithPWA(uow);

                displayPeriodMnager.Save(displayPeriod);
                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(this.ReturnError(ex, "خطا در تغییر به روزانه"));
            }
        }
        public IEnumerable <TimeSheetJson> GetTimeSheetsByDateAndNumberOfDay(PeriodNumberDateJson period)
        {
            List <TimeSheetJson> result              = new List <TimeSheetJson>();
            UnitOfWork           uow                 = new UnitOfWork();
            UserManager          userManager         = new UserManager(uow);
            ProjectManager       projectManager      = new Domain.ProjectManager(uow);
            TimeSheetManager     timeSheetManager    = new TimeSheetManager(uow);
            DisplayPeriodManager displayPeriodMnager = new DisplayPeriodManager(uow);
            var displayPeriod = DisplayPeriodUtilities.ConvertPeriodNumberDateJsonToDisplayPeriod(period);
            //SyncWithPWA(uow);
            User currUser = new UserHelper().GetCurrent();

            displayPeriodMnager.Save(displayPeriod);
            DateTime fromDate = displayPeriod.StartDate;
            DateTime toDate   = fromDate.AddDays(displayPeriod.NumOfDays);
            IEnumerable <PresenceHour> presHours = timeSheetManager.GetPresHoursByUser(currUser, fromDate, toDate);
            IEnumerable <WorkHour>     workHours = timeSheetManager.GetWorkHoursByUser(currUser, fromDate, toDate);

            result = TimeSheetAssembler.ToJsonsForRegister(presHours, workHours);

            return(result);
        }