public void Given_is_deleted_and_not_have_permissioins_When_IsEditEnabled_Then_returns_false()
        {
            // Given
            var user = new Mock<IPrincipal>();
            user
                .Setup(x => x.IsInRole(Permissions.EditGeneralandHazardousSubstancesRiskAssessments.ToString()))
                .Returns(false);

            var viewmodel = new FireRiskAssessmentSummaryViewModel(
                10L,
                55881L,
                "Some Title",
                "Some Reference",
                DateTime.Now.AddDays(-1),
                RiskAssessmentStatus.Draft,
                true,
                false
                );

            // When
            var result = viewmodel.IsEditEnabled(user.Object);

            // Then
            Assert.IsFalse(result);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest()) return;

            var riskAssessmentId = new RiskAssessmentContextFilterHelper(filterContext)
                                       {
                                           ActionParamterIdKey = "riskAssessmentId",
                                           ViewModelPropertyNameKey = "RiskAssessmentId"
                                       }
                .GetRiskAssessmentId();
            if (riskAssessmentId > 0)
            {
                var user = filterContext.HttpContext.User as CustomPrincipal;
                if (user == null)
                {
                    filterContext.Result = new HttpUnauthorizedResult();
                }

                var riskAssessment = ObjectFactory.GetInstance<IFireRiskAssessmentService>().GetRiskAssessment(riskAssessmentId, user.CompanyId);
                var summary = new FireRiskAssessmentSummaryViewModel(riskAssessment.Id,
                                                                        riskAssessment.CompanyId,
                                                                        riskAssessment.Title,
                                                                        riskAssessment.Reference,
                                                                        riskAssessment.CreatedOn.Value,
                                                                        riskAssessment.Status,
                                                                        riskAssessment.Deleted,
                                                                        riskAssessment.Status == RiskAssessmentStatus.Archived
                                                                        );
                dynamic viewBag = filterContext.Controller.ViewBag;
                viewBag.RiskAssessmentSummary = summary;
                if (riskAssessment.Status == RiskAssessmentStatus.Archived)
                {
                    viewBag.IsReadOnly = true;
                }
            }
        }