public static LinkBuilder Link(this FluentHelper helper) { var htmlHelper = helper.HtmlHelper; var component = new Link(htmlHelper); var builder = new LinkBuilder(component); return builder; }
public void LinkHtmlEncode() { var htmlHelper = MvcHelper.GetHtmlHelper(); var component = new Link(htmlHelper); var builder = new LinkBuilder(component); builder .Name<Contact, string>(c => c.Name) .Action("Schedule", "Invoice") .Text("<p>Testing</p>"); var html = builder.ToHtmlString(); html.Should().Be("<a href=\"/test/app/Invoice/Schedule\" id=\"Name\"><p>Testing</p></a>"); }
public void LinkSecureNoAccessTest() { var htmlHelper = MvcHelper.GetHtmlHelper(); var component = new Link(htmlHelper); var builder = new LinkBuilder(component); builder .Name("CreditLimit") .Action("Schedule", "Invoice") .Text("1000") .Secure("Finance", "Administrator"); var html = builder.ToHtmlString(); html.Should().Be("<a class=\"access-denied\" disabled=\"disabled\" id=\"CreditLimit\">1000</a>"); }
public void BuildResourceLinks_GlobalAndResourceConfiguration_ExpectedResult(Link global, Link resource, object expectedResult) { // Arrange var config = GetConfiguration(resourceLinks: global); var primaryResource = GetResourceContext <Article>(resourceLinks: resource); _provider.Setup(m => m.GetResourceContext("articles")).Returns(primaryResource); var builder = new LinkBuilder(config, GetRequestManager(), null, _provider.Object); // Act var links = builder.GetResourceLinks("articles", "123"); // Assert if (expectedResult == null) { Assert.Null(links); } else { Assert.Equal(_resourceSelf, links.Self); } }
private Enterprises CreateEnterprisesWithLinks() { var firstLink = new LinkBuilder().BuildRel(AbiquoRelations.FIRST).BuildHref(FIRST_HREF).GetLink(); var lastLink = new LinkBuilder().BuildRel(AbiquoRelations.LAST).BuildHref(LAST_HREF).GetLink(); var enterprises = new Enterprises() { Collection = new List <Enterprise>() { CreateEnterpriseWithLinks() } , Links = new List <Link>() { firstLink, lastLink } , TotalSize = 1 }; return(enterprises); }
public void BuildResourceLinks_GlobalAndResourceConfiguration_ExpectedResult(LinkTypes global, LinkTypes resource, object expectedResult) { // Arrange var config = GetConfiguration(resourceLinks: global); var primaryResource = GetArticleResourceContext(resourceLinks: resource); _provider.Setup(m => m.GetResourceContext("articles")).Returns(primaryResource); var builder = new LinkBuilder(config, GetRequestManager(), new PaginationContext(), _provider.Object, _queryStringAccessor); // Act var links = builder.GetResourceLinks("articles", _primaryId.ToString()); // Assert if (expectedResult == null) { Assert.Null(links); } else { Assert.Equal(_resourceSelf, links.Self); } }
private void Bind() { var pictureIdStr = Request.QueryString["picid"]; var posterIdStr = Request.QueryString["posid"]; hdnShowId.Value = Request.QueryString["showId"]; if (!string.IsNullOrEmpty(pictureIdStr)) { var pictureId = new Guid(pictureIdStr); BindPicture(pictureId); return; } else if (!string.IsNullOrEmpty(posterIdStr)) { var posterId = new Guid(posterIdStr); BindPoster(posterId); return; } Response.Redirect(LinkBuilder.DashboardLink()); }
private void Bind() { DateTime showDate; Guid showId; var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); IShow show = null; var segment = Request.GetFriendlyUrlSegments().FirstOrDefault(); //Check to see if the show date or show id is passed in then get the IShow for that show if (DateTime.TryParse(segment, out showDate)) { show = showService.GetShow(showDate); } else if (Guid.TryParse(segment, out showId)) { show = showService.GetShow(showId); } //If it is not a valid show then get out of here if (show == null) { Response.Redirect(LinkBuilder.DefaultMainLink()); } hdnShowId.Value = show.Id.ToString(); lnkPhishShows.NavigateUrl = GetPhishowsLink(showDate); lnkPhishTracks.NavigateUrl = GetPhishTracksLink(showDate); //Get the user Id and Bind the notes and tags BindNotes(show); BindTags(show.Id); BindListenedShow(show); BindSetlist(show.ShowDate.Value); }
public void Applies_cascading_settings_for_resource_links(LinkTypes linksInResourceContext, LinkTypes linksInOptions, LinkTypes expected) { // Arrange var exampleResourceContext = new ResourceContext { PublicName = nameof(ExampleResource), ResourceType = typeof(ExampleResource), ResourceLinks = linksInResourceContext }; var options = new JsonApiOptions { ResourceLinks = linksInOptions }; var request = new JsonApiRequest(); var paginationContext = new PaginationContext(); var resourceGraph = new ResourceGraph(exampleResourceContext.AsArray()); var httpContextAccessor = new FakeHttpContextAccessor(); var linkGenerator = new FakeLinkGenerator(); var controllerResourceMapping = new FakeControllerResourceMapping(); var linkBuilder = new LinkBuilder(options, request, paginationContext, resourceGraph, httpContextAccessor, linkGenerator, controllerResourceMapping); // Act ResourceLinks resourceLinks = linkBuilder.GetResourceLinks(nameof(ExampleResource), "id"); // Assert if (expected == LinkTypes.Self) { resourceLinks.Self.Should().NotBeNull(); } else { resourceLinks.Should().BeNull(); } }
public void createControl_CreatedUser(object sender, EventArgs e) { bool success = false; CreateUserWizard cont = null; try { cont = (CreateUserWizard)sender; _RoleProvider.AddUsersToRoles(new string[1] { cont.UserName }, new string[1] { Core.Membership.Roles.REGISTERED }); var profileService = new ProfileService(cont.UserName); var profile = profileService.GetUserProfile(); profile.Public = false; profile.ButtonSize = DefaultButtonSize; profile.FontSize = DefaultFontSize; profile.Save(); success = true; } catch (Exception ex) { _Log.WriteFatal("There was a major error creating a new user with a message of: " + ex.Message); } //If they successfully create a new user then send a welcome email and take them to the main page // Otherwise it will show them an error or in a fatal case it will take them to Login. if (success && cont != null) { var emailManager = new EmailManager(this.Page); emailManager.SendWelcomeEmail(cont.UserName, cont.Password, cont.Email); System.Web.Security.FormsAuthentication.RedirectFromLoginPage(cont.UserName, true); Response.Redirect(LinkBuilder.DefaultMainLink()); } }
public override void AddLinks(LinkBuilder linkBuilder) { linkBuilder.EntityId = this.ForeignEntityId; linkBuilder.RelationId = this.Id; linkBuilder.PrimaryEntityId = this.PrimaryEntityId; this.Links.Add( new Link() { Href = linkBuilder.RelationSelf(this.Id), Rel = LinkRelations.Self } ); this.Links.Add( new Link() { Href = linkBuilder.RelationPrimaryEntity(this.PrimaryEntityId), Rel = LinkRelations.PrimaryEntity } ); this.Links.Add( new Link() { Href = linkBuilder.RelationItems(), Rel = LinkRelations.RelationItems } ); foreach (var item in this.Items) { item.AddLinks(linkBuilder); } this.PrimaryEntity.AddLinks(linkBuilder); this.ForeignEntity.AddLinks(linkBuilder); }
public override void Prepare(ControllerContext controllerContext) { if (MenuAction == null) { throw new InvalidOperationException("MenuAction must be defined prior to using an ActionMenuItem"); } if (string.IsNullOrEmpty(HelpText)) { var attributes = ((MethodCallExpression)(MenuAction.Body)).Method.GetCustomAttributes( typeof(MenuHelpText), false); if (attributes.Length > 0) { HelpText = ((MenuHelpText)attributes[0]).HelpText; } } if (string.IsNullOrEmpty(ActionUrl)) { ActionUrl = LinkBuilder.BuildUrlFromExpression(controllerContext.RequestContext, RouteTable.Routes, MenuAction); } if (string.IsNullOrEmpty(Title) && string.IsNullOrEmpty(Icon)) { var attributes = ((MethodCallExpression)(MenuAction.Body)).Method.GetCustomAttributes( typeof(MenuTitle), false); if (attributes.Length > 0) { Title = ((MenuTitle)attributes[0]).Title; } else { var expression = MenuAction.Body as MethodCallExpression; if (expression != null) { Title = SplitPascalCase(expression.Method.Name); } } } base.Prepare(controllerContext); }
public void Applies_cascading_settings_for_resource_links(LinkTypes linksInResourceContext, LinkTypes linksInOptions, LinkTypes expected) { // Arrange var exampleResourceContext = new ResourceContext { PublicName = nameof(ExampleResource), ResourceType = typeof(ExampleResource), ResourceLinks = linksInResourceContext }; var resourceGraph = new ResourceGraph(exampleResourceContext.AsArray()); var request = new JsonApiRequest(); var paginationContext = new PaginationContext(); var queryStringAccessor = new EmptyRequestQueryStringAccessor(); var options = new JsonApiOptions { ResourceLinks = linksInOptions }; var linkBuilder = new LinkBuilder(options, request, paginationContext, resourceGraph, queryStringAccessor); // Act var resourceLinks = linkBuilder.GetResourceLinks(nameof(ExampleResource), "id"); // Assert if (expected == LinkTypes.Self) { resourceLinks.Self.Should().NotBeNull(); } else { resourceLinks.Should().BeNull(); } }
/// <summary> /// Returns a list of all relation items of the relation /// Usage: /// - Not used (normally retrieved with the relation) /// Includes domain object data for: /// - RelationItem /// Links: /// - www.darwin.com/project/{id}/database/{id}/entity/{id}/relation/{id}/item/{id} (relation: self) /// </summary> /// <param name="request">Request.</param> /// <param name="projectId">Project id.</param> /// <param name="databaseId">Database id.</param> /// <param name="entityId">Entity id.</param> /// <param name="relationId">Relation id.</param> /// <param name="pageSize">Page size.</param> /// <param name="pageNumber">Page number.</param> /// <returns>List of all relation items of the relation.</returns> public HttpResponseMessage Get(HttpRequestMessage request, string projectId, string databaseId, string entityId, string relationId, int pageSize = 10, int pageNumber = 0) { // Parse and validate input parameters Guid projectIdParsed = this.ParseAndValidateProjectId(request, projectId); Guid databaseIdParsed = this.ParseAndValidateDatabaseId(request, databaseId); Guid entityIdParsed = this.ParseAndValidateEntityId(request, entityId); Guid relationIdParsed = this.ParseAndValidateRelationId(request, relationId); this.ValidatePageSize(request, pageSize); this.ValidatePageNumber(request, pageNumber); // Retrieve objects var project = this.RetrieveProject(request, projectIdParsed); var database = this.RetrieveDatabase(request, databaseIdParsed, project); var entity = this.RetrieveEntity(request, entityIdParsed, database); var relation = this.RetrieveRelation(request, relationIdParsed, entity); var getObjectList = new GetObjectList <RelationItem>(); var queryResult = getObjectList.Execute(ObjectListDataSource.RelationItems, new RelationsItemsFilter(relation.Id), pageSize, pageNumber); // Add links var linkBuilder = new LinkBuilder(Url); linkBuilder.ProjectId = project.Id; linkBuilder.DatabaseId = database.Id; linkBuilder.EntityId = entity.Id; linkBuilder.PrimaryEntityId = relation.PrimaryEntityId; foreach (var relationItem in queryResult.ResultSet) { relationItem.AddLinks(linkBuilder); } // Wrap into the collection var collection = this.WrapQueryResultIntoCollection(queryResult); // Return the object return(request.CreateResponse(HttpStatusCode.OK, collection)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } string message = "If you have an account, a verification email has been sent. Please check your email."; var user = await _userManager.FindByEmailAsync(Input.Email); if (user == null) { ModelState.AddModelError(string.Empty, message); return(Page()); } var confirmLink = await LinkBuilder.GetConfirmEmailLink(_userManager, user, Request); await _emailSendingService.SendConfirmationEmail(user, confirmLink); ModelState.AddModelError(string.Empty, message); return(Page()); }
public ActionResult ArticleEdit(AdminArticleViewModel form, int id = 0) { setActiveMenuIndex(1); //сохранение Article article = id == 0 ? new Article() : dataService.GetArticle(id); if (article != null) { article.ShortText = form.ShortText; article.Text = form.Text; article.Title = form.Title; //если нет URL то прописываю if (string.IsNullOrEmpty(article.Url)) { article.Url = TextHelper.Translit(article.Title); } dataService.SaveArticle(article); return(Redirect(LinkBuilder.AdminArticles())); } return(View("ArticlePage", form)); }
public void btnEditPicture_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(hdnId.Value)) { var type = hdnId.Value.Split('=')[0]; var id = hdnId.Value.Split('=')[1]; switch (type) { case "picture": var myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>()); var myShowArt = myShowArtService.GetMyShowArt(new Guid(id)); Response.Redirect(LinkBuilder.EditArtLink(myShowArt.ArtId)); break; case "poster": var myShowPosterService = new MyShowPosterService(Ioc.GetInstance <IMyShowPosterRepository>()); var myShowPoster = myShowPosterService.GetMyShowPoster(new Guid(id)); Response.Redirect(LinkBuilder.EditPosterLink(myShowPoster.PosterId)); break; } } }
private Enterprise CreateEnterpriseWithLinks() { var propertiesLink = new LinkBuilder() .BuildRel(AbiquoRelations.PROPERTIES) .BuildHref(PROPERTIES_HREF) .BuildType(AbiquoMediaDataTypes.VND_ABIQUO_ENTERPRISEPROPERTIES) .BuildTitle(AbiquoRelations.PROPERTIES) .GetLink(); var enterprise = new Enterprise() { Id = 42 , Name = "Arbitrary Enterprise" , Links = new List <Link>() { CreateUsersLink(), propertiesLink } }; return(enterprise); }
private string GetLink() { MethodCallExpression call = LinkAction.Body as MethodCallExpression; string actionName = call.Method.Name; // TODO: Use better logic to chop off the controller suffix string controllerName = Controller.Name;// typeof(T).Name; if (controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)) { controllerName = controllerName.Remove(controllerName.Length - 10, 10); } RouteValueDictionary values = LinkBuilder.BuildParameterValuesFromExpression(call); values = values ?? new RouteValueDictionary(); values.Add("controller", controllerName); values.Add("action", actionName); VirtualPathData vpd = RouteTable.Routes.GetVirtualPath(_ctx, values); return(vpd.VirtualPath); }
public override void AddLinks(LinkBuilder linkBuilder) { linkBuilder.EntityId = this.EntityId; this.Links.Add( new Link() { Href = linkBuilder.AttributeSelf(this.Id), Rel = LinkRelations.Self } ); if (this.DataTypeId != Guid.Empty) { this.Links.Add( new Link() { Href = linkBuilder.DatabaseDataType(this.DataTypeId), Rel = LinkRelations.DataType } ); } }
public override void AddLinks(LinkBuilder linkBuilder) { linkBuilder.DatabaseId = this.DatabaseId; this.Links.Add( new Link() { Href = linkBuilder.DataTypeSelf(this.Id), Rel = LinkRelations.Self } ); if (this.BaseEnumId != Guid.Empty) { this.Links.Add( new Link() { Href = linkBuilder.DataTypeBaseEnum(this.BaseEnumId), Rel = LinkRelations.BaseEnum } ); } }
public async Task <IActionResult> OnPostSendVerificationEmailAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } if (!ModelState.IsValid) { await LoadAsync(user); return(Page()); } var confirmLink = await LinkBuilder.GetConfirmEmailLink(_userManager, user, Request); await _emailSendingService.SendConfirmationEmail(user, confirmLink); StatusMessage = "Verification email sent. Please check your email."; return(RedirectToPage()); }
public override void AddLinks(LinkBuilder linkBuilder) { linkBuilder.ProjectId = this.ProjectId; linkBuilder.DatabaseId = this.Id; this.Links.Add(new Link() { Href = linkBuilder.DatabaseSelf(this.Id), Rel = LinkRelations.Self }); this.Links.Add(new Link() { Href = linkBuilder.DatabaseDataTypes(), Rel = LinkRelations.DataTypes }); this.Links.Add(new Link() { Href = linkBuilder.DatabaseBaseEnums(), Rel = LinkRelations.BaseEnums }); this.Links.Add(new Link() { Href = linkBuilder.DatabaseEntities(), Rel = LinkRelations.Entities }); this.Links.Add(new Link() { Href = linkBuilder.DatabaseDiagrams(), Rel = LinkRelations.Diagrams }); foreach (var dataType in this.DataTypes) { dataType.AddLinks(linkBuilder); } }
public static RouteValueDictionary ParseExpression <T>(Expression <Action <T> > action) where T : Controller { var body = action.Body as MethodCallExpression; if (body == null) { throw new InvalidOperationException("Expression must be a method call"); } if (body.Object != action.Parameters[0]) { throw new InvalidOperationException("Method call must target lambda argument"); } var name = body.Method.Name; var str2 = typeof(T).Name; if (str2.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)) { str2 = str2.Remove(str2.Length - 10, 10); } var values = new RouteValueDictionary { { "controller", str2 }, { "action", name } }; if (body.Method.GetParameters().Length > 0) { var methodParams = LinkBuilder.BuildParameterValuesFromExpression(body) ?? new RouteValueDictionary(); foreach (var methodParam in methodParams) { values.Add(methodParam.Key, methodParam.Value); } } return(values); }
private void BindArt() { var artId = string.IsNullOrEmpty(Request.QueryString["id"]) ? EmptyGuid : new Guid(Request.QueryString["id"]); if (artId == EmptyGuid) { ShowError("There was an error with your request please go back and try again."); phMain.Visible = false; return; } hdnId.Value = artId.ToString(); var art = artService.GetArt(artId); var photoService = new PhotoService(Ioc.GetInstance <IPhotoRepository>()); var photo = photoService.GetPhoto(art.PhotoId); txtNotes.Text = art.Notes; ddlShow.SelectedValue = photo.ShowId.ToString(); imgDisplayFull.ImageUrl = LinkBuilder.GetImageLinkByFileName(photo.FileName); txtCreator.Text = art.Creator; }
/// <summary> /// Returns the relation /// Usage: /// - User edits the properties of the relation - to retrieve the properties /// Includes domain object data for: /// - Relation /// - RelationItem /// Links: /// - www.darwin.com/project/{id}/database/{id}/entity/{id}/relation/{id} (relation: self) /// - www.darwin.com/project/{id}/database/{id}/entity/{id}/relation/{id}/items (relation: http://www.darwin.org/rels/relationitems) /// - www.darwin.com/project/{id}/database/{id}/entity/{id}/relation/{id}/item/{id} (relation: self) /// - www.darwin.com/project/{id}/database/{id}/entity/{id} (relation: http://www.darwin.org/rels/primaryentity) /// </summary> /// <param name="request">Request.</param> /// <param name="projectId">Project id.</param> /// <param name="databaseId">Database id.</param> /// <param name="entityId">Entity id.</param> /// <param name="id">Relation id.</param> /// <returns>The relation.</returns> public HttpResponseMessage Get(HttpRequestMessage request, string projectId, string databaseId, string entityId, string id) { // Parse and validate input parameters Guid projectIdParsed = this.ParseAndValidateProjectId(request, projectId); Guid databaseIdParsed = this.ParseAndValidateDatabaseId(request, databaseId); Guid entityIdParsed = this.ParseAndValidateEntityId(request, entityId); Guid idParsed = this.ParseAndValidateId(request, id); // Retrieve objects var project = this.RetrieveProject(request, projectIdParsed); var database = this.RetrieveDatabase(request, databaseIdParsed, project); var entity = this.RetrieveEntity(request, entityIdParsed, database); var relation = this.RetrieveRelation(request, idParsed, entity); // Add links var linkBuilder = new LinkBuilder(Url); linkBuilder.ProjectId = project.Id; linkBuilder.DatabaseId = database.Id; relation.AddLinks(linkBuilder); // Return the object return(request.CreateResponse(HttpStatusCode.OK, relation)); }
public IEnumerable <DTOPlayerSalary> Convert(JsonPlayers source, IEnumerable <DTOPlayerSalary> destination, ResolutionContext context) { List <DTOPlayerSalary> playerSalaries = new List <DTOPlayerSalary>(); foreach (var p in source.data) { playerSalaries.Add(new DTOPlayerSalary() { Name = p.playerName, Salary = p.salary, Points = p.points, GamesPlayed = p.gamesPlayed, GameWinningGoals = p.gameWinningGoals, Assists = p.assists, Goals = p.goals, ProfileLink = LinkBuilder.GetPortraitLink(p.playerId), UnitPerPoint = p.salary.HasValue ? p.salary / (p.points > 0 ? p.points : 1) : null, UnitPerAssist = p.salary.HasValue ? p.salary / (p.assists > 0 ? p.assists : 1) : null, UnitPerGoal = p.salary.HasValue ? p.salary / (p.goals > 0 ? p.goals : 1) : null }); } return(playerSalaries); }
private void BindTicketStub() { var ticketStubId = string.IsNullOrEmpty(Request.QueryString["id"]) ? EmptyGuid : new Guid(Request.QueryString["id"]); if (ticketStubId == EmptyGuid) { ShowError("There was an error with your request please go back and try again."); phMain.Visible = false; return; } hdnId.Value = ticketStubId.ToString(); var ticketStub = ticketStubService.GetTicketStub(ticketStubId); var photoService = new PhotoService(Ioc.GetInstance <IPhotoRepository>()); var photo = photoService.GetPhoto(ticketStub.PhotoId); txtNotes.Text = ticketStub.Notes; ddlShow.SelectedValue = photo.ShowId.ToString(); imgDisplayFull.ImageUrl = LinkBuilder.GetImageLinkByFileName(photo.FileName); chkPTBM.Checked = ticketStub.Original; }
/// <summary> /// Returns the base enum value /// Usage: /// - User edits the properties of the base enum value - to retrieve the properties /// Includes domain object data for: /// - BaseEnumValue /// Links: /// - www.darwin.com/project/{id}/database/{id}/baseenum/{id}/value/{id} (relation: self) /// </summary> /// <param name="request">Request.</param> /// <param name="projectId">Project id.</param> /// <param name="databaseId">Database id.</param> /// <param name="baseEnumId">Base enum id.</param> /// <param name="id">Base enum value id.</param> /// <returns>The base enum value.</returns> public HttpResponseMessage Get(HttpRequestMessage request, string projectId, string databaseId, string baseEnumId, string id) { // Parse and validate input parameters Guid projectIdParsed = this.ParseAndValidateProjectId(request, projectId); Guid databaseIdParsed = this.ParseAndValidateDatabaseId(request, databaseId); Guid baseEnumIdParsed = this.ParseAndValidateBaseEnumId(request, baseEnumId); Guid idParsed = this.ParseAndValidateId(request, id); // Retrieve objects var project = this.RetrieveProject(request, projectIdParsed); var database = this.RetrieveDatabase(request, databaseIdParsed, project); var baseEnum = this.RetrieveBaseEnum(request, baseEnumIdParsed, database); var baseEnumValue = this.RetrieveBaseEnumValue(request, idParsed, baseEnum); // Add links var linkBuilder = new LinkBuilder(Url); linkBuilder.ProjectId = project.Id; linkBuilder.DatabaseId = database.Id; baseEnumValue.AddLinks(linkBuilder); // Return the object return(request.CreateResponse(HttpStatusCode.OK, baseEnumValue)); }
/// <summary> /// Returns a list of all projects. /// Usage: /// - User selects a project to open - to return the list of all projects available to user /// - Well-known entry point /// Includes domain object data for: /// - Project /// Links: /// - www.darwin.com/project/{id} (relation: self) /// </summary> /// <param name="request">Request.</param> /// <param name="pageSize">Page size.</param> /// <param name="pageNumber">Page number.</param> /// <returns>List of all projects.</returns> public HttpResponseMessage Get(HttpRequestMessage request, int pageSize = 10, int pageNumber = 0) { // Parse and validate input parameters this.ValidatePageSize(request, pageSize); this.ValidatePageNumber(request, pageNumber); // Retrieve objects var getObjectList = new GetObjectList <Project>(); var queryResult = getObjectList.Execute(ObjectListDataSource.Projects, ListFilter.Empty, pageSize, pageNumber); // Add links var linkBuilder = new LinkBuilder(Url); foreach (var project in queryResult.ResultSet) { project.AddLinks(linkBuilder); } // Wrap into the collection var collection = this.WrapQueryResultIntoCollection(queryResult); // Return the object return(request.CreateResponse(HttpStatusCode.OK, collection)); }
public void LinkSecureAccessTest() { var htmlHelper = MvcHelper.GetHtmlHelper("test.user", new[] { "Finance" }); var component = new Link(htmlHelper); var builder = new LinkBuilder(component); builder .Name("CreditLimit") .Action("Schedule", "Invoice") .Text("1000") .Secure("Finance", "Administrator"); var html = builder.ToHtmlString(); html.Should().Be("<a href=\"/test/app/Invoice/Schedule\" id=\"CreditLimit\">1000</a>"); }
public void rptSets_ItemCommand(object source, RepeaterCommandEventArgs e) { ResetPanels(); bool success = true; bool needToCommit = false; SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); Guid showId = new Guid(hdnId.Value); var show = (Show)showService.GetShow(showId); using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin()) { Guid setId = new Guid(e.CommandArgument.ToString()); var set = (Set)setService.GetSet(setId); if (set != null) { if (e.CommandName.ToLower() == "remove") { needToCommit = true; RemoveSet(set, show, ref setService); } else if (e.CommandName.ToLower() == "up") { needToCommit = true; MoveSetUp(set, show, ref setService); } else if (e.CommandName.ToLower() == "down") { needToCommit = true; MoveSetDown(set, show, ref setService); } else if (e.CommandName.ToLower() == "change") { needToCommit = true; Response.Redirect(LinkBuilder.AddSongsToSetControlLink(set.SetId, string.Format("/Admin/AddSetsToShow.aspx?id={0}", showId))); } try { if (needToCommit) { uow.Commit(); success = true; } } catch (Exception ex) { success = false; } } } DetermineSuccess(success); Bind(); }
private void Bind() { if (string.IsNullOrEmpty(Request.QueryString["showId"]) && string.IsNullOrEmpty(Request.QueryString["showDate"])) { Response.Redirect(LinkBuilder.DashboardLink()); } var showIdStr = Request.QueryString["showId"]; var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); if (string.IsNullOrEmpty(showIdStr)) { DateTime date; var success = DateTime.TryParse(Request.QueryString["showDate"], out date); if (!success) { return; } var s = showService.GetShow(date); if (s == null) { return; } showIdStr = s.ShowId.ToString(); } var showId = new Guid(showIdStr); ShowId = showId; var myShowService = new MyShowService(Ioc.GetInstance <IMyShowRepository>()); //var setSongService = new SetSongService(Ioc.GetInstance<ISetSongRepository>()); //var analysisService = new AnalysisService(Ioc.GetInstance<IAnalysisRepository>()); var ticketStubService = new TicketStubService(Ioc.GetInstance <ITicketStubRepository>()); BindReviews(showId, ref myShowService); var show = (Show)showService.GetShow(showId); SetPageTitle("Review of " + show.GetShowName()); ShowName = show.GetShowName(); //var ss = (from set in show.Sets.OrderBy(x => x.SetNumber) // from song in setSongService.GetSetSongsBySet(set.SetId).OrderBy(z => z.Order).DefaultIfEmpty() // from analysis in analysisService.GetAnalysisBySetSongAndUser(song.SetSongId, userId).DefaultIfEmpty() // select new { Set = set, Song = song, Analysis = analysis }).ToList(); ////SlideShowExtender1.ContextKey = showId.ToString(); //rptSongs.DataSource = ss; //rptSongs.DataBind(); var ticketStub = (TicketStub)ticketStubService.GetByShow(showId).FirstOrDefault(); if (ticketStub == null) { return; } phTicketStub.Visible = true; imgTicketStub.ImageUrl = LinkBuilder.GetTicketStubLink(ticketStub.Photo.FileName); }
public void Applies_cascading_settings_for_top_level_links(LinkTypes linksInResourceContext, LinkTypes linksInOptions, LinkTypes expected) { // Arrange var exampleResourceContext = new ResourceContext { PublicName = nameof(ExampleResource), ResourceType = typeof(ExampleResource), TopLevelLinks = linksInResourceContext }; var resourceGraph = new ResourceGraph(new[] { exampleResourceContext }); var request = new JsonApiRequest { PrimaryResource = exampleResourceContext, PrimaryId = "1", IsCollection = true, Kind = EndpointKind.Relationship, Relationship = new HasOneAttribute() }; var paginationContext = new PaginationContext { PageSize = new PageSize(1), PageNumber = new PageNumber(2), TotalResourceCount = 10 }; var queryStringAccessor = new EmptyRequestQueryStringAccessor(); var options = new JsonApiOptions { TopLevelLinks = linksInOptions }; var linkBuilder = new LinkBuilder(options, request, paginationContext, resourceGraph, queryStringAccessor); // Act var topLevelLinks = linkBuilder.GetTopLevelLinks(); // Assert if (expected == LinkTypes.None) { topLevelLinks.Should().BeNull(); } else { if (expected.HasFlag(LinkTypes.Self)) { topLevelLinks.Self.Should().NotBeNull(); } else { topLevelLinks.Self.Should().BeNull(); } if (expected.HasFlag(LinkTypes.Related)) { topLevelLinks.Related.Should().NotBeNull(); } else { topLevelLinks.Related.Should().BeNull(); } if (expected.HasFlag(LinkTypes.Paging)) { topLevelLinks.First.Should().NotBeNull(); topLevelLinks.Last.Should().NotBeNull(); topLevelLinks.Prev.Should().NotBeNull(); topLevelLinks.Next.Should().NotBeNull(); } else { topLevelLinks.First.Should().BeNull(); topLevelLinks.Last.Should().BeNull(); topLevelLinks.Prev.Should().BeNull(); topLevelLinks.Next.Should().BeNull(); } } }