Esempio n. 1
0
        public bool TryGetProperty(string key, out DateTime value)
        {
            var result = DateTimeProperties.TryGetValue(key, out var offsetValue);

            value = offsetValue.LocalDateTime;
            return(result);
        }
Esempio n. 2
0
        public void Add(string key, object value)
        {
            if (value == null)
            {
                return;
            }

            if (value is string stringValue)
            {
                StringProperties.Add(key, stringValue);
            }
            else if (value is byte[] binaryValue)
            {
                BinaryProperties.Add(key, binaryValue);
            }
            else if (value is bool boolValue)
            {
                BooleanProperties.Add(key, boolValue);
            }
            else if (value is DateTimeOffset dateTimeOffsetValue)
            {
                DateTimeProperties.Add(key, dateTimeOffsetValue);
            }
            else if (value is DateTime dateTimeValue)
            {
                DateTimeProperties.Add(key, dateTimeValue);
            }
            else
            {
                IntegerProperties.Add(key, Convert.ToInt64(value));
            }
        }
        private static List <PropertyInfo> GetDateTimeProperties <TEntity>()
        {
            var key = typeof(TEntity);
            List <PropertyInfo> dateTimeProperties;

            if (!DateTimeProperties.TryGetValue(key, out dateTimeProperties))
            {
                dateTimeProperties = key.GetProperties().Where(p => p.PropertyType == typeof(DateTime)).ToList();
                DateTimeProperties.Add(key, dateTimeProperties);
            }
            return(dateTimeProperties);
        }
        public async Task <ActionResult> ManagerDashboard(int employeeID)
        {
            //Set & store query
            var employeeDetails = await _rosterMeContext.Employees
                                  .Where(emp => emp.EmployeeId == employeeID)
                                  .OrderBy(emp => emp.FirstName)
                                  .ToListAsync();

            var employeeBookedShifts = await _rosterMeContext.BookedShifts
                                       .Include(bS => bS.Employee)
                                       .Include(bS => bS.Shift)
                                       //.Where(bS => bS.EmployeeId == employeeID)
                                       .OrderBy(bS => bS.Employee.LastName)
                                       .Take(5)
                                       .ToListAsync();

            var employeeAvailabilities = await _rosterMeContext.Availability
                                         .Include(avail => avail.Employee)
                                         //.Where(avail => avail.EmployeeId == employeeID)
                                         .OrderBy(avail => avail.Employee.LastName)
                                         .Take(5)
                                         .ToListAsync();

            //Create String to store logged in employee details
            String details = "";

            //Create variables to store data
            String employeeName = "";
            int    employeeAge  = 0;

            //Loop through employee details
            for (int i = 0; i < employeeDetails.Count(); i++)
            {
                //Store details
                details += "Employee ID: " + employeeDetails[i].EmployeeId +
                           "\n- Name: " + employeeDetails[i].FirstName + " " + employeeDetails[i].LastName +
                           "\n- DOB: " + employeeDetails[i].DOB +
                           "\n- Joining Date: " + employeeDetails[i].JoiningDate +
                           "\n- Position: " + employeeDetails[i].Position +
                           "\n- Role: " + employeeDetails[i].UserRole +
                           "\n- Reporting Manager ID: " + employeeDetails[i].ReportingManagerId +
                           "\n- Department ID: " + employeeDetails[i].DepartmentId
                           + "\n";

                //Store data
                employeeName = employeeDetails[i].FirstName + " " + employeeDetails[i].LastName;
                employeeAge  = DateTimeProperties.calculateYearDifferenceBetweenDateTimes
                               (
                    employeeDetails[i].DOB,
                    DateTime.Now
                               );

                //Set Session
                HttpContext.Session.SetString(SessionName, employeeName);
                HttpContext.Session.SetInt32(SessionAge, employeeAge);
            }

            //Check if employee's details are null
            if (employeeDetails == null)
            {
                /*
                 * //Return message
                 * return Content(LOG_TAG + ": The Employee details are null" +
                 *  "\n- Employee Details query result: " + employeeDetails.Count
                 * );
                 */
            }
            else
            {
                /*
                 * //Return message
                 * return Content(LOG_TAG + ": The Employee details are not null" +
                 *  "\n- Employee Details query result: " + employeeDetails.Count +
                 *  "\n\nEmployee details:" +
                 *  "\n" + details
                 * );
                 */
            }

            //Store employee details in View Data
            ViewData["EmployeeDetails"]        = employeeDetails;
            ViewData["EmployeeBookedShifts"]   = employeeBookedShifts;
            ViewData["EmployeeAvailabilities"] = employeeAvailabilities;

            //Store employee details in Model
            var model = new Dashboard
            {
                Employees = employeeDetails
            };

            //Return View
            return(View(model));
        }
Esempio n. 5
0
 public bool TryGetProperty(string key, out DateTimeOffset value)
 {
     return(DateTimeProperties.TryGetValue(key, out value));
 }