private void FillSubLinks() { var parentID = DataConverter.ToNullableGuid(Request["ID"]); if (parentID == null) { return; } var entities = (from n in DataContext.LP_Links where n.DateDeleted == null && n.ParentID == parentID orderby n.OrderIndex, n.DateCreated select n).ToList(); var converter = new LinkEntityModelConverter(DataContext); var models = (from n in entities let m = converter.Convert(n) select m).ToList(); var model = new LinksModel(); model.List = models; subLinksControl.Model = model; }
/// <summary> /// Opens and read links csv file. /// </summary> /// <param name="path">file path</param> /// <returns>List of LinksFileModel</returns> public static IList <LinksModel> GetLinksListFromCsv(string path) { List <LinksModel> res = new List <LinksModel>(); using (TextFieldParser csvParser = new TextFieldParser(path)) { csvParser.CommentTokens = new string[] { "#" }; csvParser.SetDelimiters(new string[] { ";" }); csvParser.HasFieldsEnclosedInQuotes = true; // csvParser.ReadLine() // if headers while (csvParser.EndOfData) { var temp = new LinksModel(); string[] fields = csvParser.ReadFields(); if (!String.IsNullOrWhiteSpace(fields[0])) { temp.rawUrl = fields[0]; res.Add(temp); } } } return(res); }
public LinksModel SelectById(int id) { LinksModel model = new LinksModel(); string sqlConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("Links_SelectById", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", id); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { model = Mapper(reader); } } conn.Close(); } return(model); }
private void FillMainLinks() { var page = Page as BasePage; if (page == null) { return; } var dbContext = page.DataContext; var entities = (from n in dbContext.LP_Links where n.DateDeleted == null && n.ParentID == null orderby n.OrderIndex, n.DateCreated select n).ToList(); var converter = new LinkEntityModelConverter(dbContext); var models = (from n in entities let m = converter.Convert(n) select m).ToList(); var model = new LinksModel(); model.List = models; mainLinksControl.Model = model; }
public List <LinksModel> SelectAll() { List <LinksModel> linksList = new List <LinksModel>(); string sqlConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("Links_SelectAll", conn)) { cmd.CommandType = CommandType.StoredProcedure; SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { LinksModel model = Mapper(reader); linksList.Add(model); } } conn.Close(); } return(linksList); }
// // GET: /Links/ public ActionResult Index() { //Create a list List <LinksModel> newList = new List <LinksModel>(); //Create first item LinksModel newLinksModel = new LinksModel { ID = 1, Description = "Sup Yo?", Comments = "Chillin over here" }; //Create first item LinksModel newLinksModel2 = new LinksModel { ID = 2, Description = "Sup Homie?", Comments = "Chillin over there" }; //Add the items to our list newList.Add(newLinksModel); newList.Add(newLinksModel2); //return View(); return(View(newList)); }
private static LinksModel BuildLinks(IEnumerable <string> paths, string relatedTo) { LinksModel result = new LinksModel(); foreach (string path in paths) { PathTypeEnum type = path.GetPathType(); switch (type) { case PathTypeEnum.Directory: result.Directories.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathOpenUri(path))); break; case PathTypeEnum.File: result.Files.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathOpenUri(path))); break; case PathTypeEnum.NonExistent: result.NonExists.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathUri(path))); break; } } return(result); }
public bool Update(LinksModel model) { bool res = false; string sqlConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("Links_Update", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", model.Id); cmd.Parameters.AddWithValue("@Title", model.Title); cmd.Parameters.AddWithValue("@Url", model.Url); cmd.ExecuteNonQuery(); res = true; } conn.Close(); } return(res); }
public ActionResult Add(LinksModel model) { model.CreateOn = DateTime.Now; var result = linksService.CreateModel(model) ? SuccessTip() : ErrorTip(); return(Json(result)); }
public static void WritePathLists(this MarkdownBuilder builder, IEnumerable <string> paths, string relatedTo) { LinksModel model = BuildLinks(paths, relatedTo); WritePathsWithHeader(model.Directories, $"Directories ({model.Directories.Count})", builder); WritePathsWithHeader(model.Files, $"Files ({model.Files.Count})", builder); WritePathsWithHeader(model.NonExists, $"Non-Existing ({model.NonExists.Count})", builder); }
public ActionResult Index() { ILinksRepository context = new LinksRepository(); LinksModel model = new LinksModel(); model.links = context.UserLinks(); return(View(model)); }
public static void WritePathList(this MarkdownBuilder builder, IEnumerable <string> paths, string relatedTo) { LinksModel model = BuildLinks(paths, relatedTo); WritePaths(model.Directories, builder); WritePaths(model.Files, builder); WritePaths(model.NonExists, builder); }
private LinksModel CrieLinkParaAtualizacao() { var link = new LinksModel { Titulo = "Atualizacao", Descricao = "Atualizacao" }; return(link); }
private LinksModel CrieLinkParaCadastro() { var link = new LinksModel { Titulo = "Cadastro", Descricao = "Cadastro", Link = "https://jenkins.e-guru.com.br/BS/mattosfilho_bs_ci/User" }; return(link); }
private LinksModel Mapper(SqlDataReader reader) { LinksModel model = new LinksModel(); int index = 0; model.Id = reader.GetInt32(index++); model.Title = reader.GetString(index++); model.Url = reader.GetString(index++); return(model); }
public HttpResponseMessage Post(LinksModel model) { try { LinksService svc = new LinksService(); int res = svc.Create(model); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage SelectById(int id) { LinksModel res = new LinksModel(); LinksService svc = new LinksService(); try { res = svc.SelectById(id); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Update(LinksModel model) { bool res = false; LinksService svc = new LinksService(); try { res = svc.Update(model); return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public IHttpActionResult PostLinksModel() { var httpUrl = HttpContext.Current.Request.Form["Url"]; LinksModel linksModel = db.Links.Find(httpUrl); // Not found if (linksModel == null) { return(Json(new { URL = httpUrl, state = "not_found", rating = "0" })); } // Certified FAKE if (linksModel.IsFalseCertified) { return(Json(new { URL = httpUrl, state = "certified_fake", rating = "-100" })); } // Certified TRUE if (linksModel.IsTrueCertified) { return(Json(new { URL = httpUrl, state = "certified_ok", rating = "100" })); } // Search in Raties var ratiesModel = db.Raties .Where(b => b.Link == httpUrl) .FirstOrDefault(); if (ratiesModel == null) { return(Json(new { URL = httpUrl, state = "dont_know", rating = "0" })); } else { var ratingCalculated = linksModel.UrlRating; if (ratingCalculated <= 0) { return(Json(new { URL = httpUrl, state = "fake", rating = ratingCalculated.ToString() })); } else { return(Json(new { URL = httpUrl, state = "ok", rating = ratingCalculated.ToString() })); } } }
public void FixtureSetUp() { var portalUI = new PortalUI(ComponenteDeTela); portalUI.InicializarElementos(); var adminUI = new AdministracaoUI(ComponenteDeTela, portalUI); adminUI.InicializarElementos(); _linksInicioUI = new LinksInicioUI(ComponenteDeTela, adminUI); _linksInicioUI.AbrirFuncionalidade(); _modelParaCadastro = CrieLinkParaCadastro(); _modelParaAtualizacao = CrieLinkParaAtualizacao(); }
private void FillDataGrid() { var entities = (from n in DataContext.LP_Links where n.DateDeleted == null orderby n.OrderIndex, n.DateCreated select n).ToList(); var converter = new LinkEntityModelConverter(DataContext); var models = (from n in entities let m = converter.Convert(n) select m).ToList(); var model = new LinksModel(); model.List = models; linksControl.Model = model; }
public static void WritePathOverview(this MarkdownBuilder builder, IEnumerable <string> paths, string relatedTo) { LinksModel model = BuildLinks(paths, relatedTo); if (model.Directories.Count > 0) { builder.Bullet($"Directories ({model.Directories.Count})"); } if (model.Files.Count > 0) { builder.Bullet($"Files ({model.Files.Count})"); } if (model.NonExists.Count > 0) { builder.Bullet($"Non-Existing ({model.NonExists.Count})"); } }
public IActionResult Index() { var model = new LinksModel(); model.Links = new List <Link>() { new Link { Text = "Simple link to a 'Home' controller 'Index' action", URL = Url.Action("Index", "Home") }, new Link { Text = "A link with parameters to 'Home' controller 'Details' action", URL = Url.Action("Details", "Home", new { name = "John Doe", id = 100500 }) }, new Link { Text = "Safely generated link with parameters to 'Home' controller 'Details' action", URL = Url.Action(nameof(HomeController.Details), Utils.GetControllerName <HomeController>(), new { name = "John Doe", id = 100500 }) } }; return(View(model)); }
public int Create(LinksModel model) { int res = 0; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("Links_Insert", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Title", model.Title); cmd.Parameters.AddWithValue("@Url", model.Url); SqlParameter param = new SqlParameter("@Id", SqlDbType.Int); param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.ExecuteNonQuery(); res = (int)cmd.Parameters["@Id"].Value; } conn.Close(); } return(res); }
public TaskElementModel(LinksModel l) { this.link = l.rawUrl; }
public BaseResponse <LinksModel> SaveLinks(LinksModel request) { return(base.Save <links, LinksModel>(request, (q) => q.Id == request.Id)); }
public JsonResult List(LinksModel filter, PageInfo pageInfo) { var result = linksService.GetListByFilter(filter, pageInfo); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(LinksModel model) { var result = linksService.UpdateModel(model) ? SuccessTip() : ErrorTip(); return(Json(result)); }
public ActionResult Create(LinksModel model, string cdts) { GetConditions(cdts); model.Insert(); return(View("AdminIndex")); }
public ActionResult Edit(LinksModel model, string cdts) { GetConditions(cdts); model.Update(); return(RedirectToAction("AdminIndex", new { Page = model.Page, Cdts = cdts })); }