public async Task <IActionResult> PutLink(int id, LinkDto link) { CommonResponse <LinkDto> response = new CommonResponse <LinkDto>(); if (id != link.Id) { response.Error = new Error { Status = 400, Message = "There was a mismatch with the provided id and the object." }; return(BadRequest(response)); } // Maps to model Link linkModel = _mapper.Map <Link>(link); _context.Entry(linkModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LinkExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static LinkDto CreateLink(ILinkRule rule, bool ruleApply, LinkStatus linkStatus) { var linkDto = new LinkDto("link", linkStatus.ToString(), 1); rule.SetLinkTo(ruleApply, linkStatus, linkDto); return(linkDto); }
public async Task CreateLink(LinkDto link) { var json = JsonConvert.SerializeObject(link); var resp = await _httpClient.PostAsync($"/api/blogs/{link.BlogId}/links", new StringContent(json, Encoding.UTF8, "application/json")); resp.EnsureSuccessStatusCode(); }
private IEnumerable <WeatherDataDto> ProcessLink(LinkDto link) { var result = Enumerable.Empty <WeatherDataDto>(); switch (link.Provider) { case Provider.Gismeteo: result = this.gismeteoProvider.Fetch(link.Url); break; case Provider.Sinoptik: result = this.sinoptikProvider.Fetch(link.Url); break; case Provider.Rp5: result = this.rp5Provider.Fetch(link.Url); break; } foreach (var item in result) { item.CityId = link.CityId; } return(result); }
public void IsRuleApplicable_RuleApplicable(string link) { var linkDto = new LinkDto(link, "Hey", 1); var rule = new ReadmeFileLinkRules(""); Assert.IsTrue(rule.IsRuleApplicable(linkDto), "Link should have been relevant"); }
private void SearchLink() { string projectCode = CommonHandler.GetComboBoxSelectedValue(cboProject).ToString(); string chapterCode = CommonHandler.GetComboBoxSelectedValue(cboChapter).ToString(); List <LinkDto> linkList = new List <LinkDto>(); DataSet ds = webService.SearchLink(projectCode, chapterCode); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { LinkDto link = new LinkDto(); link.CharterCode = Convert.ToString(ds.Tables[0].Rows[i]["CharterCode"]); link.CharterName = Convert.ToString(ds.Tables[0].Rows[i]["CharterName"]); link.LinkCode = Convert.ToString(ds.Tables[0].Rows[i]["LinkCode"]); link.LinkName = Convert.ToString(ds.Tables[0].Rows[i]["LinkName"]); link.OrderNO = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderNO"]); link.LinkContent = Convert.ToString(ds.Tables[0].Rows[i]["LinkContent"]); link.InDateTime = Convert.ToDateTime(ds.Tables[0].Rows[i]["InDateTime"]); link.InUserID = Convert.ToString(ds.Tables[0].Rows[i]["InUserID"]); linkList.Add(link); } grcLink.DataSource = linkList; } else { CommonHandler.ShowMessage(MessageType.Information, "没有数据"); grcLink.DataSource = null; } }
private void SearchLink() { string[] chapterCodeSearch = _chapterCode.Split(','); List <LinkDto> sourcelinkList = new List <LinkDto>(); string projectCode = CommonHandler.GetComboBoxSelectedValue(cboProject).ToString(); for (int i = 0; i < chapterCodeSearch.Length; i++) { string chapterCode = chapterCodeSearch[i].ToString(); DataSet ds = service.SearchLink(projectCode, chapterCode); if (ds.Tables.Count > 0) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { LinkDto link = new LinkDto(); link.CharterName = Convert.ToString(ds.Tables[0].Rows[j]["CharterName"]); link.LinkCode = Convert.ToString(ds.Tables[0].Rows[j]["LinkCode"]); link.LinkName = Convert.ToString(ds.Tables[0].Rows[j]["LinkName"]); link.LinkContent = Convert.ToString(ds.Tables[0].Rows[j]["LinkContent"]); //inspection.InspectionStandardName = Convert.ToString(ds.Tables[0].Rows[i]["InspectionStandardName"]); sourcelinkList.Add(link); } } } grcLink.DataSource = sourcelinkList; }
public void IsRuleApplicable_RuleApplicable(string link) { var linkDto = new LinkDto(link, "Hey", 1); var repositoryLinkRule = new RepositoryLinkRule(A.Fake <IRepository>(), A.Fake <IReadmeFile>()); Assert.IsTrue(repositoryLinkRule.IsRuleApplicable(linkDto), "Link should have been relevant"); }
public void IsLinkValid_LinkNotValid(string link) { var linkDto = new LinkDto(link, "Hey", 1); var internetLinkRule = new InternetLinkRule(); Assert.AreEqual(LinkStatus.Bad, internetLinkRule.IsLinkValid(linkDto), "Link should not have been valid"); }
public void IsRuleApplicable_RuleApplicable(string link) { var linkDto = new LinkDto(link, "Hey", 1); var internetLinkRule = new InternetLinkRule(); Assert.IsTrue(internetLinkRule.IsRuleApplicable(linkDto), "Link should have been relevant"); }
public HttpResponseMessage Update([FromUri] Guid linkId, [FromBody] LinkDto link) { link.Id = linkId; var argument = new UpdateLinkArgument() { Link = Mapper.Map <ExtendedLinkModel>(link) }; argument.Link.MusicDestinations = link.MusicDestinations?.GroupBy(x => x.IsoCode.ToUpper()).ToDictionary(x => x.Key, x => x.Select(Mapper.Map <Service.Models.Link.Music.DestinationModel>).ToList()); argument.Link.TicketDestinations = link.TicketDestinations?.GroupBy(x => x.IsoCode.ToUpper()) .ToDictionary(x => x.Key, x => x.Select(Mapper.Map <Service.Models.Link.Ticket.DestinationModel>).ToList()); var result = _updateCommand.Execute(argument); var mapped = Mapper.Map <LinkDto>(result); mapped.MusicDestinations = result.MusicDestinations?.SelectMany(x => x.Value.Select(d => { var dest = Mapper.Map <Service.Models.Link.Music.DestinationModel, MusicDestinationDto>(d); dest.IsoCode = x.Key; return(dest); }).ToList() ).ToList(); mapped.TicketDestinations = result.TicketDestinations?.SelectMany(x => x.Value.Select(d => { var dest = Mapper.Map <Service.Models.Link.Ticket.DestinationModel, TicketDestinationDto>(d); dest.IsoCode = x.Key; return(dest); }).ToList() ).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, mapped)); }
/// <summary> /// /// </summary> /// <param name="projectCode"></param> /// <param name="chapterCode"></param> /// <param name="combox"></param> public static void BindLink(string projectCode, string chapterCode, ComboBoxEdit combox) { List <LinkDto> linkList = new List <LinkDto>(); LinkDto l = new LinkDto(); l.LinkCode = ""; l.LinkName = "全部"; linkList.Add(l); //DataSet ds = webService.SearchLink(projectCode, chapterCode); DataSet ds = null; if (IsNetWork) { ds = webService.SearchLink(projectCode, chapterCode); } else { localService.Url = "http://192.168.1.99/XHX.YiQiServer/service.asmx"; ds = localService.SearchLink(projectCode, chapterCode); } if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { LinkDto link = new LinkDto(); link.LinkCode = Convert.ToString(ds.Tables[0].Rows[i]["LinkCode"]); link.LinkName = Convert.ToString(ds.Tables[0].Rows[i]["LinkName"]); linkList.Add(link); } } CommonHandler.SetComboBoxEditItems(combox, linkList, "LinkName", "LinkCode"); }
private IList <LinkDto> GetLinksForTournament(Guid tournamentId, Guid teamId) { return(new List <LinkDto> { LinkDto.DeleteLink(Url.Link(nameof(LeaveTournament), new { teamId, tournamentId })), LinkDto.AllLink(Url.Link(nameof(GetTeamTournaments), new { teamId })) }); }
private IList <LinkDto> GetLinksForRight(Guid rightId) { return(new List <LinkDto> { LinkDto.SelfLink(Url.Link(nameof(GetRightById), new { rightId })), LinkDto.AllLink(Url.Link(nameof(GetRights), null)) }); }
private LinkViewModel CreateLinkViewModel(LinkDto l) { return(new LinkViewModel() { LinkTxt = l.LinkTxt, LinkUrl = !string.IsNullOrEmpty(l.LinkUrl) ? l.LinkUrl : "javascript:void" }); }
public void IsLinkValid_LinkNotValid(string link, string actualFile) { var linkDto = new LinkDto(link, "Hey", 1); var repository = new FakeRepository(actualFile); var repositoryLinkRule = new RepositoryLinkRule(repository, A.Fake <IReadmeFile>()); Assert.AreEqual(LinkStatus.Bad, repositoryLinkRule.IsLinkValid(linkDto), "Link should not have been valid"); }
private IList <LinkDto> GetLinksForLanguage(Guid languageId) { return(new List <LinkDto> { LinkDto.SelfLink(Url.Link(nameof(GetLanguageById), new { languageId })), LinkDto.AllLink(Url.Link(nameof(GetLanguages), null)) }); }
public LinkDto CreateUserLink(Guid id) { var links = new LinkDto(Url.Link("UpdateUser", new { id }), "update_user", "PUT"); return(links); }
private IList <LinkDto> GetLinksForTeam(Guid teamId) { return(new List <LinkDto> { LinkDto.CreateLink(Url.Link(nameof(CreateTeam), null)), LinkDto.SelfLink(Url.Link(nameof(GetTeamById), new { teamId })) }); }
public LinkDto CreateUserLink() { var links = new LinkDto(Url.Link("AddUser", null), "Subscribe", "POST"); return(links); }
public void SameLinkDiffrentLines_AreEqualeReturnsTrue(string link, string text) { var link1 = new LinkDto(link, text, 1); var link2 = new LinkDto(link, text, 2); Assert.AreEqual(link1, link2, "The links should have been equale"); Assert.AreEqual(link1.GetHashCode(), link2.GetHashCode(), "The links should have the same hase code"); }
public void IsLinkValid_LinkNotValid(string link, string header) { var linkDto = new LinkDto(link, "Hey", 1); var readmeFile = new StringReadmeFile("SomeText", header, "SomeText"); var rule = new ReadmeFileLinkRules(readmeFile.GetAllText()); Assert.AreEqual(LinkStatus.Bad, rule.IsLinkValid(linkDto), "Link should not have been valid"); }
private IList <LinkDto> GetLinksForParticipation(Guid participationId) { return(new List <LinkDto> { LinkDto.SelfLink(Url.Link(nameof(GetParticipationSessionById), new { participationId })), LinkDto.AuthLink(Url.Link(nameof(AuthenticateUserOnParticipation), new { participationId })), new(Url.Link(nameof(RunExecutionParticipation), new { participationId }), "execution", HttpMethod.Post) });
private void btnLinkAddRow_Click(object sender, EventArgs e) { LinkDto link = new LinkDto(); link.CharterCode = CommonHandler.GetComboBoxSelectedValue(cboChapter).ToString(); link.CharterName = cboChapter.Text; dataHandlerLink.AddRow(link); }
private LinkDto CreateLinkForBooks(Guid authorId) { var link = new LinkDto(_urlHelper.Link("GetBooksForAuthor", new { id = authorId }), "self", "GET"); return(link); }
public static Link Load(LinkDto dto) { return(new Link() { Name = dto.Name, Url = dto.Url, Description = dto.Description }); }
private void grvLink_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { LinkDto link = grvLink.GetRow(e.RowHandle) as LinkDto; if (e.Column == gbChapterCode || e.Column == gbChapterName || (e.Column == gcLinkCode && link.StatusType != 'I')) { e.Appearance.BackColor = Color.Gray; } }
private IList <LinkDto> GetLinksForUser(Guid userId) { return(new List <LinkDto> { LinkDto.SelfLink(Url.Link(nameof(GetUserById), new { userId })), LinkDto.DeleteLink(Url.Link(nameof(DeleteUserById), new { userId })), LinkDto.AllLink(Url.Link(nameof(GetAllUsers), null)), }); }
private IList <LinkDto> GetLinksForParticipation(Guid participationId) { return(new List <LinkDto> { LinkDto.CreateLink(Url.Link(nameof(CreateParticipation), null)), LinkDto.SelfLink(Url.Link(nameof(GetParticipationById), new { participationId })), LinkDto.AllLink(Url.Link(nameof(GetParticipations), null)) }); }
private IList <LinkDto> GetLinksForTest(Guid stepId, Guid testId) { return(new List <LinkDto> { LinkDto.SelfLink(Url.Link(nameof(GetTestById), new { testId })), LinkDto.CreateLink(Url.Link(nameof(StepsController.AddTest), new { stepId, testId })), LinkDto.AllLink(Url.Link(nameof(GetTests), null)) }); }