public ActionResult SignOut()
        {
            try
            {
                Attendance attendance = AttendancesLogic.GetLastSignByUserId(SessionData.UserId);
                AttendancesLogic.UpdateAttendance(attendance);
                ActionRate actionRate = ActionRatesLogic.GetActionRateByName("Sign Out");
                EmployeePointsLogic.InsertNewEmployeePoint(new EmployeePoint()
                {
                    ActionRateId = actionRate.Id,
                    Date         = DateTimeHelper.Today(),
                    UserId       = attendance.EmpUserId,
                    Rate         = actionRate.MaxRate
                });

                return(RedirectToAction("UserSign"));
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/Attendances/SignOut"
                });
                return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = Error.ServerNotRespond }));
            }
        }
        public static void EvaluateStandUpMeeting(StandUpMeetingDetails standUpMeetingDetails)
        {
            ActionRate    actionRateStandUp    = ActionRatesRepositories.GetActionRateByName("Stand Up Meeting");
            EmployeePoint standUpEmployeePoint = new EmployeePoint
            {
                ActionRateId = actionRateStandUp.Id,
                Date         = DateTimeHelper.Today(),
                UserId       = standUpMeetingDetails.UserId,
                Rate         = standUpMeetingDetails.TotalDegree
            };

            if (standUpMeetingDetails.StandUpEmployeePointId > 0)
            {
                standUpEmployeePoint.Id = standUpMeetingDetails.StandUpEmployeePointId;
                EmployeePointsRepositories.UpdateEmployeePoint(standUpEmployeePoint);
            }
            else
            {
                EmployeePointsRepositories.InsertNewEmployeePoint(standUpEmployeePoint);
                standUpMeetingDetails.StandUpEmployeePointId = standUpEmployeePoint.Id;
            }

            ActionRate    actionRateSuggestion    = ActionRatesRepositories.GetActionRateByName("Suggestion Bonus");
            EmployeePoint suggestionEmployeePoint = new EmployeePoint
            {
                ActionRateId = actionRateSuggestion.Id,
                Date         = DateTimeHelper.Today(),
                UserId       = standUpMeetingDetails.UserId,
                Rate         = standUpMeetingDetails.SuggestionDegree
            };

            if (standUpMeetingDetails.SuggestionEmployeePointId > 0)
            {
                suggestionEmployeePoint.Id = standUpMeetingDetails.SuggestionEmployeePointId;
                EmployeePointsRepositories.UpdateEmployeePoint(suggestionEmployeePoint);
            }
            else
            {
                EmployeePointsRepositories.InsertNewEmployeePoint(suggestionEmployeePoint);
                standUpMeetingDetails.SuggestionEmployeePointId = suggestionEmployeePoint.Id;
            }
            StandUpMeetingRepository.EvaluateStandUpMeeting(standUpMeetingDetails);
        }
        public ActionResult SignIn(string latitude = "", string longitude = "")
        {
            try
            {
                Attendance attendancee = new Attendance();

                DateTime signInDate = DateTimeHelper.Today();
                if (signInDate != null)
                {
                    signInDate = DateTimeHelper.Today();
                }
                else
                {
                    return(RedirectToAction("UserSign", "Attendances", new { ErrorMessage = "Error in Time Server Connection", parameter = "" }));
                }

                if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude) && signInDate.Hour < 12)
                {
                    Attendance attendance = new Attendance()
                    {
                        EmpUserId  = SessionData.UserId,
                        SignInDate = signInDate,
                        Latitude   = latitude,
                        Longitude  = longitude
                    };
                    AttendancesLogic.InsertNewAttendance(attendance);
                    ActionRate actionRate = ActionRatesLogic.GetActionRateByName("Sign In");
                    EmployeePointsLogic.InsertNewEmployeePoint(new EmployeePoint()
                    {
                        ActionRateId = actionRate.Id,
                        Date         = DateTime.Now,
                        UserId       = attendance.EmpUserId,
                        Rate         = actionRate.MaxRate
                    });
                }
                else if (signInDate.Hour >= 12)
                {
                    LogsLogic.InsertLog(new Log()
                    {
                        Message    = "this User breake the client side validation and try to signin within not correct time or maybe change his system time by mistck",
                        StackTrace = "",
                        Parameters = "user id = " + SessionData.UserId + " and username = "******"ManagementProject/Attendances/SignIn"
                    });
                    return(RedirectToAction("UserSign", "Attendances", new { errorMessage = "Your Time System is not Correct!" }));
                }
                else if (string.IsNullOrEmpty(latitude) || string.IsNullOrEmpty(longitude))
                {
                    LogsLogic.InsertLog(new Log()
                    {
                        Message    = "this User breake the client side validation and try to signin within not correct geoLocation or maybe something was wrong happened!",
                        StackTrace = "",
                        Parameters = "user id = " + SessionData.UserId + " and username = "******"SignIn"
                    });
                    return(RedirectToAction("UserSign", "Attendances", new { errorMessage = "Please check Location Permissions to allow to Signin!" }));
                }
                List <StandUpMeetingDetails> model = StandUpMeetingsLogic.GetTodayStandUpMeeting(SessionData.UserId);
                if (model.Count == 0)
                {
                    return(RedirectToAction("Create", "StandUpMeet"));
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/Attendances/SignIn"
                });
                return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = Error.ServerNotRespond }));
            }
        }