public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TProperty1, TProperty2>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TProperty1> > expression, Expression <Func <TModel, TProperty2> > displayExpression, IEnumerable <SelectListItem> selectList, string optionLabel, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); var label = HtmlHelperLabelExtensions.LabelFor(html, expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { string controlName = GetExpressionParam <TModel, TProperty1>(expression); string initScript = string.Format("<script>$(document).ready(function () {{ $('#{0}').combobox(); }});</script>", controlName); var contents = html.DropDownListFor(expression, selectList, optionLabel, new { @class = "form-control" }); string result = String.Concat( GetString(contents), initScript ); return(new HtmlString(result)); } string l = GetString(html.HiddenFor(expression)); if (appUserSvc.HasAccess(displayRights)) { var contents = html.DisplayFor(displayExpression); string result = GetString(contents); return(new HtmlString(result + l)); } return(new HtmlString(l)); }
public bool HasAccess(IPrincipal contextUser, OperationSet operationSet) { bool result = false; result = _applicationUserService.HasAccess(operationSet); return(result); }
public static IHtmlContent RPCSAutocompleteEnumDropDownList <TModel, TEnum>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TEnum> > expression, SelectList selectList, OperationSet editRights, OperationSet displayRights) { if (expression == null) { throw new ArgumentNullException("expression"); } if (!typeof(TEnum).IsEnum) { throw new ArgumentException("TEnum"); } var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); var label = html.LabelFor(expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights) || appUserSvc.HasAccess(displayRights)) { var contents = html.DropDownListFor(expression, selectList, new { @class = "form-control" }); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } return(new HtmlString("")); }
public static IHtmlContent RPCSAutocompleteEnumDropDownList <TModel, TEnum, TProperty>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TEnum> > expression, Expression <Func <TModel, TProperty> > displayExpression, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (expression == null) { throw new ArgumentNullException("expression"); } if (!typeof(TEnum).IsEnum) { throw new ArgumentException("TEnum"); } var label = html.LabelFor(expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { string controlName = GetExpressionParam <TModel, TEnum>(expression); string initScript = string.Format("<script>$(document).ready(function () {{ $('#{0}').combobox(); }});</script>", controlName); var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider); IList <SelectListItem> selectList = Enum.GetValues(typeof(TEnum)).Cast <TEnum>() .Select(x => new SelectListItem { Text = ((Enum)(object)x).GetAttributeOfType <DisplayAttribute>().Name, Value = Convert.ToUInt64(x).ToString() }).ToList(); var contents = html.DropDownListFor(expression, selectList, new { @class = "form-control" }); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } string l = GetString(html.HiddenFor(expression)); if (appUserSvc.HasAccess(displayRights)) { var contents = html.DisplayFor(displayExpression); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:8px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result + l)); } return(new HtmlString(l)); }
public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TValue1, TValue2>( this HtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, OperationSet editRights, OperationSet displayRights) { return(RPCSAutocompleteDropDownList <TModel, TValue1, TValue2>(html, labelExpression, valueExpression, editRights, displayRights, null)); }
public void TestInitial() { var simulation = new Simulation(1, 2, 3); var operationSet = new OperationSet(3, simulation); var description = operationSet.GetDescription(); var expected = "1: Fylle flaske 1 fra springen\n" + "2: Fylle flaske 1 fra springen\n" + "3: Fylle flaske 1 fra springen\n"; Assert.AreEqual(expected, description); }
public void CanRedoNak() { var mock1 = new MockUndo(true); var mock2 = new MockUndo(); var operationSet = new OperationSet(this); operationSet.Add(mock1); operationSet.Add(mock2); Assert.IsFalse(operationSet.CanRedo); }
public void TestNext3() { var simulation = new Simulation(1, 2, 3); var operationSet = new OperationSet(2, simulation); var success = true; for (var i = 0; i < 64; i++) { success = operationSet.Next(); } Assert.IsFalse(success); }
public void TestNext() { var simulation = new Simulation(1, 2, 3); var operationSet = new OperationSet(3, simulation); var success = operationSet.Next(); var description = operationSet.GetDescription(); var expected = "1: Fylle flaske 1 fra springen\n" + "2: Fylle flaske 1 fra springen\n" + "3: Fylle flaske 2 fra springen\n"; Assert.AreEqual(expected, description); Assert.IsTrue(success); }
public void RedoTest() { var mock1 = new MockUndo(true); var mock2 = new MockUndo(true); var operationSet = new OperationSet(this); operationSet.Add(mock1); operationSet.Add(mock2); operationSet.Redo(); Assert.IsTrue(mock1.RedoCalled); Assert.IsTrue(mock2.RedoCalled); }
public void UndoOrderTest() { var finalValue = 0; var mock1 = new MockUndo(true); var operationSet = new OperationSet(this); operationSet.Add(mock1); operationSet.Add(new ActionUndo(this, () => finalValue = 1)); operationSet.Add(new ActionUndo(this, () => finalValue = 2)); operationSet.Undo(); Assert.IsTrue(mock1.UndoCalled); Assert.AreEqual(1, finalValue); }
public void TestNext2() { var simulation = new Simulation(1, 2, 3); var operationSet = new OperationSet(3, simulation); for (var i = 0; i < 8; i++) { operationSet.Next(); } var description = operationSet.GetDescription(); var expected = "1: Fylle flaske 1 fra springen\n" + "2: Fylle flaske 2 fra springen\n" + "3: Fylle flaske 1 fra springen\n"; Assert.AreEqual(expected, description); }
public bool HasAccess(OperationSet operationSet) { bool result = false; result = _applicationUser.Role.Operations.Contains(operationSet); if (result == true && _applicationUser.Role.PayrollAccessOperations.Contains(operationSet)) { if (IsHasOwnOOLogin() == false) { result = false; } } return(result); }
public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TValue1, TValue2>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, OperationSet editRights, OperationSet displayRights, object htmlAttributes) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); var label = html.LabelFor(labelExpression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { var dropDown = GenerateAutocompleteDropDown(html, labelExpression, htmlAttributes); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(dropDown), "</div>", "</div>"); return(new HtmlString(result)); } string l = GetString(html.HiddenFor(labelExpression)); if (appUserSvc.HasAccess(displayRights)) { var contents = html.DisplayFor(valueExpression); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:8px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result + l)); } return(new HtmlString(l)); }
public static IHtmlContent RPCSDropDownList <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, string name, IEnumerable <SelectListItem> selectList, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { var contents = HtmlHelperSelectExtensions.DropDownList(html, name, selectList, new { @class = "form-control" }); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } if (appUserSvc.HasAccess(displayRights)) { IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)), GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)), "</div>"); return(new HtmlString(result)); } string v = GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)); string l = GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)); return(new HtmlString(v + l)); }
public static IHtmlContent RPCSEditorFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, OperationSet EditorRights, OperationSet displayRights, string toolTip = "", string errorMessage = "") { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(EditorRights)) { return(GenerateEditor(html, expression, toolTip, errorMessage, label)); } if (appUserSvc.HasAccess(displayRights)) { return(GenerateLabel(html, expression, label)); } return(HtmlHelperInputExtensions.HiddenFor(html, expression)); }
public static IHtmlContent RPCSDisplayTitleViewActionWithPermissionFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, string linkText, string action, string controller, object routeValues, OperationSet displayRights, bool isBlank = false) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(displayRights)) { var urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>(); IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, expression); var anchor = new TagBuilder("a"); anchor.InnerHtml.Append(contents.ToString()); anchor.Attributes["href"] = urlHelper.Action(action, controller, routeValues); anchor.Attributes["title"] = string.IsNullOrEmpty(linkText) ? "" : linkText; if (isBlank) { anchor.Attributes["target"] = "_blank"; anchor.Attributes["rel"] = "noopener noreferrer"; } return(new HtmlString(GetString(anchor))); } else { return(HtmlHelperDisplayExtensions.DisplayFor(html, expression)); } }
public static IHtmlContent RPCSDisplayTitleViewActionWithPermissionFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, string linkText, string action, object routeValues, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(displayRights)) { return(GenerateAnchor(html, expression, linkText, action, routeValues)); } else { return(html.DisplayFor(expression)); } }
public static IHtmlContent RPCSDisplayWithItemDetailsViewActionForEmployee <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, int employeeId, OperationSet displayRights, string itemController, object itemRouteValues, OperationSet viewItemDetailsRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); bool hasAccess = appUserSvc.HasAccess(displayRights); if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.HasAccess(Operation.EmployeeSubEmplPersonalDataView)) { hasAccess = hasAccess || appUserSvc.IsDepartmentManagerForEmployee(employeeId); } if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.GetEmployeeID() == employeeId) { hasAccess = true; } if (hasAccess) { IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" }); IHtmlContent contents = null; var value = ExpressionMetadataProvider.FromLambdaExpression(valueExpression, html.ViewData, html.MetadataProvider).Model; if (appUserSvc.HasAccess(viewItemDetailsRights) && value != null && String.IsNullOrEmpty(value.ToString()) == false) { var urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>(); string linkText = value.ToString(); var anchor = new TagBuilder("a"); anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText); anchor.Attributes["href"] = urlHelper.Action("Details", itemController, itemRouteValues); anchor.Attributes["target"] = "_blank"; contents = new HtmlString(GetString(anchor)); } else { contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression); } string result = String.Concat("<div class=\"row\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:6px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } return(new HtmlString("")); // html.HiddenFor(expression); }
public static IHtmlContent RPCSDisplayFor <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(displayRights)) { IHtmlContent label = html.LabelFor(labelExpression, new { @class = "control-label col-md-4" }); IHtmlContent contents = html.DisplayFor(valueExpression); string result = String.Concat("<div class=\"row\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:6px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } return(new HtmlString("")); // html.HiddenFor(expression); }
public static IHtmlContent IconActionWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, object routeValues, OperationSet operationSet, string classAnchor, string glyphiconClass) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { return(GenerateGlyphicon(htmlHelper, linkText, action, routeValues, classAnchor, glyphiconClass)); } return(new HtmlString("")); }
public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, OperationSet operationSet) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { return(GenerateAnchor(htmlHelper, linkText, action)); } return(null); }
/// <summary> /// Overridden Constructor /// </summary> /// <param name="operationSet">The OperationSet of this Brack application.</param> public RAM(OperationSet operationSet) : this(null, operationSet) { }
public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, object routeValues, OperationSet operationSet) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { return(GenerateAnchor(htmlHelper, linkText, action, routeValues)); } return(new HtmlString("")); //TODO Не уверен что вот так будет работать }
public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, string controller, object routeValues, object htmlAttributes, OperationSet operationSet) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { return(GenerateAnchorWithAttributes(htmlHelper, linkText, action, controller, htmlAttributes, routeValues)); } return(new HtmlString("")); }
public static IHtmlContent RPCSDisplayProjectTitleView <TModel, TValue>(this IHtmlHelper <TModel> html, Project project, Expression <Func <TModel, TValue> > expression, string linkText, string action, object routeValues, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(displayRights) && appUserSvc.IsMyProject(project) || appUserSvc.HasAccess(editRights)) { var actionContext = _serviceProvider.GetService <IActionContextAccessor>().ActionContext; var urlHelper = (IUrlHelper) new UrlHelper(actionContext); IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, expression); var anchor = new TagBuilder("a"); anchor.InnerHtml.AppendHtml(contents); anchor.Attributes["href"] = urlHelper.Action(action, "Project", routeValues); anchor.Attributes["title"] = string.IsNullOrEmpty(linkText) ? "" : linkText; return(new HtmlString(GetString(anchor))); } else { return(html.DisplayFor(expression)); } }
//TODO Доделать!!! public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, string controller, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes, OperationSet operationSet) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { //string value = UrlHelper.GenerateUrl(protocol, hostName, new VirtualPathData(_urlHelper.ActionContext,,new RouteValueDictionary(routeValues)), fragment); var anchor = new TagBuilder("a"); anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText); anchor.MergeAttributes(new RouteValueDictionary(htmlAttributes)); //anchor.MergeAttribute("href", value); return(new HtmlString(GetString(anchor))); } return(new HtmlString("")); }
//TODO доделать!!! public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, string controller, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes, OperationSet operationSet) { //NOT TESTED!!!! var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { //string value = UrlHelper.GenerateUrl(linkText, action, controller, protocol, hostName, fragment, routeValues, null, _urlHelper.ActionContext, false); TagBuilder anchor = new TagBuilder("a"); anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText); anchor.MergeAttributes <string, object>(htmlAttributes); //anchor.MergeAttribute("href", value); return(new HtmlString(GetString(anchor))); } return(new HtmlString("")); }
public static IHtmlContent RPCSDisplayForEmployee <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, int employeeId, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); bool hasAccess = appUserSvc.HasAccess(displayRights); if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.HasAccess(Operation.EmployeeSubEmplPersonalDataView)) { hasAccess = hasAccess || appUserSvc.IsDepartmentManagerForEmployee(employeeId); } if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.GetEmployeeID() == employeeId) { hasAccess = true; } if (hasAccess) { var label = html.LabelFor(labelExpression, new { @class = "control-label col-md-4" }); var contents = html.DisplayFor(valueExpression); string result = String.Concat("<div class=\"row\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:6px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } return(new HtmlString("")); // html.HiddenFor(valueExpression); }
public static IHtmlContent ActionLinkWithPermission(this IHtmlHelper htmlHelper, string linkText, string action, string controller, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes, OperationSet operationSet) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); if (appUserSvc.HasAccess(operationSet)) { var urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>(); var anchor = new TagBuilder("a"); anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText); anchor.Attributes["href"] = urlHelper.Action(action, controller, routeValues); anchor.MergeAttributes(new RouteValueDictionary(htmlAttributes)); return(new HtmlString(GetString(anchor))); } return(new HtmlString("")); }