Пример #1
0
        public ActionResult Edit(int?personnelId, int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var overtime = HRBusinessService.RetrieveOvertime(UserOrganisationId, id.Value);

            if (overtime == null)
            {
                return(HttpNotFound());
            }

            bool isAdmin = User.IsInRole("Admin");

            var  overtimePreferences = HRBusinessService.RetrieveOvertimePreferences(UserOrganisationId);
            var  overtimeSummary     = HRBusinessService.RetrieveOvertimeSummary(UserOrganisationId, personnelId.Value);
            var  permissions         = HRBusinessService.RetrievePersonnelPermissions(isAdmin, UserOrganisationId, personnelId.Value);
            bool canApproveOvertime  = HRBusinessService.CanApproveOvertime(UserOrganisationId, id.Value, isAdmin, ApplicationUser.Id);
            var  viewModel           = new OvertimeViewModel
            {
                Overtime            = overtime,
                OvertimePreferences = new SelectList(overtimePreferences, "OvertimePreferenceId", "Name"),
                OvertimeSummary     = overtimeSummary,
                CanApprovedOvertime = canApproveOvertime,
                Permissions         = permissions
            };

            return(View(viewModel));
        }
Пример #2
0
 public ActionResult CanApproveOvertime(int personnelId, int id)
 {
     try
     {
         var organisationId = UserOrganisationId;
         var isAdmin        = User.IsInAnyRoles("Admin");
         return(this.JsonNet(HRBusinessService.CanApproveOvertime(organisationId, id, isAdmin, ApplicationUser.Id)));
     }
     catch (Exception ex)
     {
         return(this.JsonNet(ex));
     }
 }