public void Setup() { _siteId = Guid.NewGuid(); _menuId = Guid.NewGuid(); var menuRepositoryMock = new Mock <IMenuRepository>(); var pageRepositoryMock = new Mock <IPageRepository>(); var languageRepositoryMock = new Mock <ILanguageRepository>(); languageRepositoryMock.Setup(x => x.GetAll(_siteId)).Returns(new List <Language>() { new Language(), new Language() }); var cacheManagerMock = new Mock <ICacheManager>(); var mapperMock = new Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <MenuAdminModel>(It.IsAny <Menu>())).Returns(new MenuAdminModel()); var roleServiceMock = new Mock <IRoleService>(); _sut = new MenuFacade(menuRepositoryMock.Object, pageRepositoryMock.Object, languageRepositoryMock.Object, cacheManagerMock.Object, mapperMock.Object, roleServiceMock.Object); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menuFacade) : this(oidStrategy, req) { //this.objectFacade = objectFacade; //spec = objectFacade.Specification; //IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade); //cachedId = oid.InstanceId; CachedType = menuFacade.Id; }
public MenuService(IMenuFacade menuFacade) { if (menuFacade == null) { throw new ArgumentNullException("menuFacade"); } _menuFacade = menuFacade; }
public RestSnapshot(IOidStrategy oidStrategy, IMenuFacade menu, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(oidStrategy, req, true) { populator = () => { HttpStatusCode = httpStatusCode; Representation = MenuRepresentation.Create(oidStrategy, menu, req, flags); SetHeaders(); }; }
protected ListRepresentation(IOidStrategy oidStrategy, IMenuFacade[] menus, HttpRequestMessage req, RestControlFlags flags) : base(oidStrategy, flags) { Value = menus.Select(c => CreateMenuLink(oidStrategy, req, c)).ToArray(); SelfRelType = new ListRelType(RelValues.Self, SegmentValues.Services, new UriMtHelper(oidStrategy, req)); SetLinks(req); SetExtensions(); SetHeader(true); }
private void SetMembers(IMenuFacade menu, HttpRequestMessage req, List <LinkRepresentation> tempLinks) { var actionFacades = menu.MenuItems.SelectMany(i => GetMenuItem(i)); InlineActionRepresentation[] actions = actionFacades.Select(a => InlineActionRepresentation.Create(OidStrategy, req, a.Item2, Flags)).ToArray(); Members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object)m)); }
private void SetLinksAndMembers(HttpRequestMessage req, IMenuFacade menu) { var tempLinks = new List <LinkRepresentation> { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags) }; SetMembers(menu, req, tempLinks); Links = tempLinks.ToArray(); }
protected MenuRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menu, RestControlFlags flags) : base(oidStrategy, flags) { var helper = new UriMtHelper(oidStrategy, req, menu); SetScalars(menu); SelfRelType = new MenuRelType(RelValues.Self, helper); SetLinksAndMembers(req, menu); SetExtensions(menu); SetHeader(menu); }
public NavigationViewComponent(IContextService contextService, IMenuFacade menuFacade, IUserService userService) : base(contextService) { _contextService = contextService; _menuFacade = menuFacade; _userService = userService; }
public RestSnapshot(IOidStrategy oidStrategy, IMenuFacade menu, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(oidStrategy, req, true) { populator = () => { this.httpStatusCode = httpStatusCode; representation = MenuRepresentation.Create(oidStrategy, menu, req, flags); SetHeaders(); }; }
public MenuController(IMenuFacade menuFacade, ICommandSender commandSender, IMenuRules menuRules, IContextService contextService) : base(contextService) { _menuFacade = menuFacade; _commandSender = commandSender; _menuRules = menuRules; }
private void SetExtensions(IMenuFacade menu) { if (Flags.SimpleDomainModel) { //Extensions = RestUtils.GetExtensions(objectFacade.Specification.SingularName, objectFacade.Specification.Description, objectFacade.Specification.PluralName, objectFacade.Specification.DomainTypeName(OidStrategy), objectFacade.Specification.IsService, null, null, null, null, null, GetCustomExtensions(objectFacade), null, null, OidStrategy); Extensions = MapRepresentation.Create(); } else { Extensions = MapRepresentation.Create(); } }
private void SetMembers(IMenuFacade menu, HttpRequestMessage req, List <LinkRepresentation> tempLinks) { var actionFacades = menu.MenuItems.SelectMany(i => GetMenuItem(i)).Where(af => IsVisibleAndUsable(af.Item2)); InlineActionRepresentation[] actions = actionFacades.Select(a => InlineActionRepresentation.Create(OidStrategy, req, a.Item2, Flags)).ToArray(); var eq = new Eq(); // todo fix distinct actions = actions.Distinct(eq).ToArray(); Members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object)m)); }
private void SetLinksAndMembers(HttpRequestMessage req, IMenuFacade menu) { var tempLinks = new List<LinkRepresentation>(); tempLinks.Add(LinkRepresentation.Create(OidStrategy, SelfRelType, Flags)); if (Flags.FormalDomainModel) { //tempLinks.Add(LinkRepresentation.Create(OidStrategy, new DomainTypeRelType(RelValues.DescribedBy, new UriMtHelper(OidStrategy, req, menu.Specification)), Flags)); } // temp disable icons //tempLinks.Add(LinkRepresentation.Create(new IconRelType(objectUri), Flags)); SetMembers(menu, req, tempLinks); Links = tempLinks.ToArray(); }
private void SetLinksAndMembers(HttpRequestMessage req, IMenuFacade menu) { var tempLinks = new List <LinkRepresentation>(); tempLinks.Add(LinkRepresentation.Create(OidStrategy, SelfRelType, Flags)); if (Flags.FormalDomainModel) { //tempLinks.Add(LinkRepresentation.Create(OidStrategy, new DomainTypeRelType(RelValues.DescribedBy, new UriMtHelper(OidStrategy, req, menu.Specification)), Flags)); } // temp disable icons //tempLinks.Add(LinkRepresentation.Create(new IconRelType(objectUri), Flags)); SetMembers(menu, req, tempLinks); Links = tempLinks.ToArray(); }
private static MvcHtmlString MenuAsHtml(this HtmlHelper html, IMenuFacade menu, IObjectFacade nakedObject, bool isEdit, bool defaultToEmptyMenu) { var descriptors = new List <ElementDescriptor>(); foreach (IMenuItemFacade item in menu.MenuItems) { ElementDescriptor descriptor; if (IsDuplicateAndIsVisibleActions(html, item, menu.MenuItems, nakedObject)) { //Test that both items are in fact visible //The Id is set just to preseve backwards compatiblity string id = menu.Id; if (id.EndsWith("Actions")) { id = id.Split('-').First() + "-DuplicateAction"; } descriptor = new ElementDescriptor { TagType = "div", Value = item.Name, Attributes = new RouteValueDictionary(new { id, @class = IdConstants.ActionName, title = MvcUi.DuplicateAction }) }; } else { descriptor = MenuItemAsElementDescriptor(html, item, nakedObject, isEdit); } if (descriptor != null) { //Would be null for an invisible action descriptors.Add(descriptor); } } if (descriptors.Count == 0 && !defaultToEmptyMenu) { return(null); } return(CommonHtmlHelper.BuildMenuContainer(descriptors, IdConstants.MenuContainerName, menu.Id, menu.Name)); }
private void SetMembers(IMenuFacade menu, HttpRequest req) { ActionContextFacade SetMenuId(ActionContextFacade action) { action.MenuId = menu.Id; return(action); } var actionFacades = menu.MenuItems.SelectMany(i => GetMenuItem(i)).Where(af => IsVisibleAndUsable(af.action)).ToArray(); var actions = actionFacades.Select(a => InlineActionRepresentation.Create(OidStrategy, req, SetMenuId(a.action), Flags)).ToArray(); var actionComparer = new ActionComparer(); actions = actions.Distinct(actionComparer).ToArray(); Members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object)m)); }
private LinkRepresentation CreateMenuLink(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menu) { var helper = new UriMtHelper(oidStrategy, req, menu); var rt = new MenuRelType(helper); return(LinkRepresentation.Create(oidStrategy, rt, Flags, new OptionalProperty(JsonPropertyNames.Title, menu.Name))); }
public RestaurantsController(IRestaurantFacade restaurantFacade, IMenuFacade menuFacade, IFeedBackFacade feedBackFacade) { _restaurantFacade = restaurantFacade; _menuFacade = menuFacade; _feedBackFacade = feedBackFacade; }
public MenuController(IQuery query, IMenuQuery menuQuery, IMenuFacade menuFacade) { this._query = query; this._menuQuery = menuQuery; this._menuFacade = menuFacade; }
private static ElementDescriptor SubMenuAsElementDescriptor(this HtmlHelper html, IMenuFacade subMenu, IObjectFacade nakedObject, bool isEdit) { string tagType = "div"; string value = CommonHtmlHelper.WrapInDiv(subMenu.Name, IdConstants.MenuNameLabel).ToString(); RouteValueDictionary attributes = new RouteValueDictionary(new { @class = IdConstants.SubMenuName, @id = subMenu.Id }); var visibleSubMenuItems = subMenu.MenuItems.Select(item => html.MenuItemAsElementDescriptor(item, nakedObject, isEdit)).Where(x => x != null); if (visibleSubMenuItems.Any()) { return(new ElementDescriptor { TagType = tagType, Value = value, Attributes = attributes, Children = visibleSubMenuItems.WrapInCollection("div", new { @class = IdConstants.SubMenuItemsName }) }); } return(null); }
private void SetScalars(IMenuFacade menu) { Title = menu.Name; MenuId = menu.Id; }
public RestSnapshot(IOidStrategy oidStrategy, IFrameworkFacade frameworkFacade, IMenuFacade menu, HttpRequest req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(oidStrategy, req, true) { populator = logger => { HttpStatusCode = httpStatusCode; Representation = MenuRepresentation.Create(oidStrategy, frameworkFacade, menu, req, flags); SetHeaders(logger); }; }
private LinkRepresentation CreateMenuLink(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menu) { var helper = new UriMtHelper(oidStrategy, req, menu); var rt = new MenuRelType(helper); return LinkRepresentation.Create(oidStrategy, rt, Flags, new OptionalProperty(JsonPropertyNames.Title, menu.Name)); }
public static MenuRepresentation Create(IOidStrategy oidStrategy, IMenuFacade menu, HttpRequestMessage req, RestControlFlags flags) { return(new MenuRepresentation(oidStrategy, req, menu, flags)); }
private void SetHeader(IMenuFacade menu) { caching = CacheType.NonExpiring; //SetEtag(objectContext.Target); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequest req, IMenuFacade menuFacade) : this(oidStrategy, req) => CachedType = menuFacade.Id;
public MenuController(IMenuFacade menuFacade, IContextService contextService) : base(contextService) { _menuFacade = menuFacade; }
public RestSnapshot(IOidStrategy oidStrategy, IMenuFacade[] menus, HttpRequestMessage req, RestControlFlags flags) : this(oidStrategy, req, true) { logger.DebugFormat("RestSnapshot:MenuList"); populator = () => { representation = ListRepresentation.Create(oidStrategy, menus, req, flags); SetHeaders(); }; }
public MenusController(IMenuFacade menuFacade, ICategoryFacade categoryFacade, IitemFacade itemFacade) { _categoryFacade = categoryFacade; _menuFacade = menuFacade; _itemFacade = itemFacade; }
public static ListRepresentation Create(IOidStrategy oidStrategy, IMenuFacade[] menus, HttpRequestMessage req, RestControlFlags flags) { return new ListRepresentation(oidStrategy, menus, req, flags); }
private void SetExtensions(IMenuFacade menu) { Extensions = MapRepresentation.Create(); }
private static ElementDescriptor SubMenuAsElementDescriptor(this HtmlHelper html, IMenuFacade subMenu, IObjectFacade nakedObject, bool isEdit) { string tagType = "div"; string value = CommonHtmlHelper.WrapInDiv(subMenu.Name, IdConstants.MenuNameLabel).ToString(); RouteValueDictionary attributes = new RouteValueDictionary(new { @class = IdConstants.SubMenuName, @id = subMenu.Id }); var visibleSubMenuItems = subMenu.MenuItems.Select(item => html.MenuItemAsElementDescriptor(item, nakedObject, isEdit)).Where(x => x != null); if (visibleSubMenuItems.Any()) { return new ElementDescriptor { TagType = tagType, Value = value, Attributes = attributes, Children = visibleSubMenuItems.WrapInCollection("div", new {@class = IdConstants.SubMenuItemsName}) }; } return null; }
private void SetHeader(IMenuFacade menu) { Caching = CacheType.NonExpiring; }
private static MvcHtmlString MenuAsHtml(this HtmlHelper html, IMenuFacade menu, IObjectFacade nakedObject, bool isEdit, bool defaultToEmptyMenu) { var descriptors = new List<ElementDescriptor>(); foreach (IMenuItemFacade item in menu.MenuItems) { ElementDescriptor descriptor; if (IsDuplicateAndIsVisibleActions(html, item, menu.MenuItems, nakedObject)) { //Test that both items are in fact visible //The Id is set just to preseve backwards compatiblity string id = menu.Id; if (id.EndsWith("Actions")) { id = id.Split('-').First() + "-DuplicateAction"; } descriptor = new ElementDescriptor { TagType = "div", Value = item.Name, Attributes = new RouteValueDictionary(new { id, @class = IdConstants.ActionName, title = MvcUi.DuplicateAction }) }; } else { descriptor = MenuItemAsElementDescriptor(html, item, nakedObject, isEdit); } if (descriptor != null) { //Would be null for an invisible action descriptors.Add(descriptor); } } if (descriptors.Count == 0 && !defaultToEmptyMenu) { return null; } return CommonHtmlHelper.BuildMenuContainer(descriptors, IdConstants.MenuContainerName, menu.Id, menu.Name); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menuFacade) : this(oidStrategy, req) { CachedType = menuFacade.Id; }
public NavigationViewComponent(IContextService contextService, IMenuFacade menuFacade) : base(contextService) { _menuFacade = menuFacade; }
public static MenuRepresentation Create(IOidStrategy oidStrategy, IMenuFacade menu, HttpRequestMessage req, RestControlFlags flags) { return new MenuRepresentation(oidStrategy, req, menu, flags); }
public static MenuRepresentation Create(IOidStrategy oidStrategy, IFrameworkFacade frameworkFacade, IMenuFacade menu, HttpRequest req, RestControlFlags flags) => new MenuRepresentation(oidStrategy, frameworkFacade, req, menu, flags);
private void SetMembers(IMenuFacade menu, HttpRequestMessage req, List<LinkRepresentation> tempLinks) { var actionFacades = menu.MenuItems.SelectMany(i => GetMenuItem(i)); InlineActionRepresentation[] actions = actionFacades.Select(a => InlineActionRepresentation.Create(OidStrategy, req, a.Item2, Flags)).ToArray(); Members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object) m)); }