Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        public ActionResult Index()
        {
            ILinksRepository context = new LinksRepository();
            LinksModel       model   = new LinksModel();

            model.links = context.UserLinks();
            return(View(model));
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        private LinksModel CrieLinkParaAtualizacao()
        {
            var link = new LinksModel
            {
                Titulo    = "Atualizacao",
                Descricao = "Atualizacao"
            };

            return(link);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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));
            }
        }
Exemplo n.º 17
0
        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));
            }
        }
Exemplo n.º 18
0
        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));
            }
        }
Exemplo n.º 19
0
        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() }));
                }
            }
        }
Exemplo n.º 20
0
        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();
        }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
        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})");
            }
        }
Exemplo n.º 23
0
        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));
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
 public TaskElementModel(LinksModel l)
 {
     this.link = l.rawUrl;
 }
Exemplo n.º 26
0
 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));
        }
Exemplo n.º 29
0
 public ActionResult Create(LinksModel model, string cdts)
 {
     GetConditions(cdts);
     model.Insert();
     return(View("AdminIndex"));
 }
Exemplo n.º 30
0
 public ActionResult Edit(LinksModel model, string cdts)
 {
     GetConditions(cdts);
     model.Update();
     return(RedirectToAction("AdminIndex", new { Page = model.Page, Cdts = cdts }));
 }