コード例 #1
0
        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 }));
            }
        }
コード例 #2
0
        public ActionResult Index()
        {
            try
            {
                if (SessionData.UserRole == UserRoles.Employee)
                {
                    Attendance attendance = AttendancesLogic.GetLastSignByUserId(SessionData.UserId);
                    if (attendance == null)
                    {
                        DateTime serverTime = DateTimeHelper.Today();
                        if (serverTime.Hour >= 12)
                        {
                            return(RedirectToAction("Index", "Employees"));
                        }
                        else
                        {
                            return(RedirectToAction("UserSign", "Attendances"));
                        }
                    }
                    List <StandUpMeetingDetails> model = StandUpMeetingsLogic.GetTodayStandUpMeeting(SessionData.UserId);
                    if (model.Count == 0)
                    {
                        return(RedirectToAction("Create", "StandUpMeet"));
                    }
                    return(RedirectToAction("Index", "Employees"));
                }
                else
                {
                    HomeIndexModel model = new HomeIndexModel();
                    model.Projects = ProjectsLogic.GetProjectlist();

                    List <Sprint> sprints = SprintsLogic.GetAllSprints();
                    model.PreviousSprint = sprints.FindLast(a => a.PreviousSprint);
                    model.CurrentSprint  = sprints.Find(a => a.CurrentSprint);
                    model.FutureSprint   = sprints.Find(a => a.FutureSprint);

                    model.CanCreateSprint = !sprints.Any(a => a.FutureSprint);
                    return(View(model));
                }
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/Projects/GetProjectlist",
                });
                return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = Error.ServerNotRespond }));
            }
        }
コード例 #3
0
        public ActionResult UserSign(string errorMessage = "")
        {
            SignInModel model = new SignInModel();

            try
            {
                Attendance attendance = AttendancesLogic.GetLastSignByUserId(SessionData.UserId);
                model.CurrentDateTime = DateTimeHelper.Today();

                model.UserName = SessionData.UserName;
                if (attendance != null)
                {
                    model.LastSignIn = (DateTime)attendance.SignInDate;
                    if (attendance.SignOutDate != null)
                    {
                        model.lastSignOut = (DateTime)attendance.SignOutDate;
                    }
                    SignHelper.PrepareSign(model);
                }
                model.Succeeded = true;
                if (!string.IsNullOrWhiteSpace(errorMessage))
                {
                    model.ErrorMessage = errorMessage;
                }
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "ManagementProject/Attendances/UserSign"
                });
                model.Succeeded    = false;
                model.ErrorMessage = "Failed To Sign in";
                return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = "Error in server Connection", parameter = "" }));
            }

            return(View(model));
        }