コード例 #1
0
        public async Task <bool> ConfirmDayFromCallendar(DateTime date, Employee employee)
        {
            try
            {
                var confirmed    = new DayActions();
                var get_schedule = _scheduleService.SimpleScheduleWithOverTimes(employee, new List <DateTime>()
                {
                    date
                }).FirstOrDefault();
                if (get_schedule != null)
                {
                    confirmed.EmployeeID     = employee.EmployeeID;
                    confirmed.FromDateID     = get_schedule.Date;
                    confirmed.ToDateID       = get_schedule.Date;
                    confirmed.CodeID         = _context.Codes.Where(x => x.Code == "PRA").Select(x => x.CodeID).FirstOrDefault();
                    confirmed.Confirmed      = true;
                    confirmed.ConfirmedBy    = employee.EmployeeID;
                    confirmed.SubmissionDate = DateTime.Now.ToLocalTime();
                    confirmed.From           = get_schedule.From;
                    confirmed.To             = get_schedule.To;
                    confirmed.FromShift      = get_schedule.FromFormated;
                    confirmed.ToShift        = get_schedule.ToFormated;
                    _context.DayActions.Add(confirmed);
                    await _context.SaveChangesAsync();

                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(false);
        }
コード例 #2
0
        public void AddWorkday()
        {
            var lastDayActions = _fileRepo.GetLatestActions();
            var fileEmployees  = _fileRepo.GetUsers();

            AddEmployees(fileEmployees);

            var dbDayActions = new DayActions(lastDayActions);

            dbDayActions.UsersActions = GetUserActions(fileEmployees, lastDayActions);

            _context.DayActions.Add(dbDayActions);
            _context.SaveChanges();
        }