Beispiel #1
0
        // GET: Links
        public async Task <IActionResult> Index(int?page)
        {
            var viewModel = new LinkViewModel();

            if (page > 0)
            {
                var links = await _context.Link.
                            Where(l => l.AddingDate.CompareTo(DateTime.Now.AddDays(-5)) > 0).
                            OrderByDescending(l => l.AddingDate).
                            ToListAsync();

                viewModel.Pagination = new Pagination(true, (int)page);

                int skipAmount  = viewModel.Pagination.Size * ((int)page - 1);
                int takeAmount  = viewModel.Pagination.Size;
                int pagesAmount = links.Count() / viewModel.Pagination.Size;

                viewModel.Pagination.PagesAmount = pagesAmount;
                viewModel.Links = links.Skip(skipAmount).Take(takeAmount);
            }

            else
            {
                viewModel.Pagination = new Pagination();
                viewModel.Links      = await _context.Link.
                                       Where(l => l.AddingDate.CompareTo(DateTime.Now.AddDays(-5)) > 0).
                                       OrderByDescending(l => l.AddingDate).
                                       ToListAsync();
            }

            return(View(viewModel));
        }
Beispiel #2
0
        public ActionResult Create(LinkViewModel model, HttpPostedFileBase photoUpload)
        {
            try
            {
                using (var ctx = new LinkEntity())
                {
                    ctx.Links.Add(new LinkDataModel {
                        Id          = model.Id,
                        Description = model.Description,
                        LinkAdress  = model.LinkAdress,
                        Title       = model.Title,
                        ImgSrc      = $" /Photos/{photoUpload.FileName}"
                    });
                    ctx.SaveChanges();
                }

                photoUpload.SaveAs(Path.Combine(Server.MapPath("~/Photos"), photoUpload.FileName));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public LinkOptionsWindow(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _downloadSignatureCollection.AddRange(Settings.Instance.Global_TrustSignatures);

            _downloadSignatureListView.ItemsSource = _downloadSignatureCollection;

            foreach (var item in Settings.Instance.Global_LinkItems)
            {
                var viewModel = new LinkViewModel();
                viewModel.Signature = item.Signature;
                viewModel.TrustSignatures.AddRange(item.TrustSignatures);
                viewModel.DeleteSignatures.AddRange(item.DeleteSignatures);

                _uploadLinkCollection.Add(viewModel);
            }

            _uploadLinkListView.ItemsSource = _uploadLinkCollection;

            this.Sort();
        }
Beispiel #4
0
        public async Task <IActionResult> Post([FromBody] LinkViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            if (model.Name == "")
            {
                return(BadRequest("Name is empty"));
            }
            if (model.Path == "")
            {
                return(BadRequest("Path is empty"));
            }
            if (model.DirectoryId == Guid.Empty)
            {
                return(BadRequest("DirectoryId is empty"));
            }

            Link link = new Link()
            {
                Name = model.Name,
                Path = model.Path,
                DirectoryInformationId = model.DirectoryId
            };

            var d = _context.Links.Add(link);
            await _context.SaveChangesAsync();

            return(Ok(d.Entity));
        }
Beispiel #5
0
        public ActionResult SairGrupo(LinkViewModel model)
        {
            int Id;

            if (int.TryParse(Util.Decrypt(model.Hash), out Id))
            {
                var gru  = db.Grupo.Find(Id);
                var aux2 = db.Users.Find(User.Identity.GetUserId <int>()).Grupos.Where(q => q.Id == gru.Id);
                if (aux2.Any())
                {
                    Grupo grupo = aux2.First();
                    db.Users.Find(User.Identity.GetUserId <int>()).Grupos.Remove(grupo);
                    db.SaveChanges();
                    TempData["Alerta"] = "Bem sucedido";
                    TempData["Classe"] = "green-alert";
                }
                else
                {
                    TempData["Alerta"] = "Grupo não encontrado";
                    TempData["Classe"] = "yellow-alert";
                }
            }
            else
            {
                TempData["Alerta"] = "Algo deu errado";
                TempData["Classe"] = "yellow-alert";
            }

            return(RedirectToAction("Inicio", "Home"));
        }
Beispiel #6
0
        public async Task <IActionResult> Create(int?id)
        {
            // If someone goes directly to /Links/Create without an Bag ID
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            LinkViewModel lvm = new LinkViewModel();

            // Load up the bag
            var allbags = await _cache.GetFromTable(_context.Bags);

            lvm.Bag = allbags.FirstOrDefault(x => x.Id == id);

            // Get the full list of people
            lvm.People = await _cache.GetFromTable(_context.People);

            // The link is for this bag
            lvm.Link       = new Linksmvccore();
            lvm.Link.BagId = lvm.Bag.Id;

            // List all the people sorted by lastname
            lvm.Options = lvm.People.OrderBy(x => x.LastName).Select(a =>
                                                                     new SelectListItem
            {
                Value = a.PersonNumber.ToString(),
                Text  = a.FirstName + ' ' + a.MiddleName + ' ' + a.LastName
            }).ToList();

            return(View(lvm));
        }
Beispiel #7
0
        public ActionResult CancelarAssinatura(LinkViewModel model)
        {
            int Id;

            if (int.TryParse(Util.Decrypt(model.Hash), out Id))
            {
                var grupo     = db.Grupo.Find(Id);
                var IsSandBox = ConfigurationManager.AppSettings["IsSandBox"];
                var path      = "";
                if (IsSandBox == "True")
                {
                    path = "https://ws.sandbox.pagseguro.uol.com.br/v2/pre-approvals/cancel/{preApprovalCode}?email={email}&token={token}";
                }
                else
                {
                    path = "https://ws.pagseguro.uol.com.br/v2/pre-approvals/cancel/{preApprovalCode}?email={email}&token={token}";
                }

                var pag = grupo.Pagamento;

                IDictionary <string, string> data = GetResponse(path, pag.Code);
                pag.Status          = Status.Cancelada;
                db.Entry(pag).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("PremiumPropaganda"));
            }
            TempData["Alerta"] = "Algo deu errado";
            TempData["Classe"] = "yellow-alert";
            return(RedirectToAction("Inicio", "Home"));
        }
Beispiel #8
0
    public async Task <LinkListViewModel> GetLinkListViewModelAsync(int certificateId,
                                                                    string userId,
                                                                    CancellationToken cancellationToken = default)
    {
        var certificate = await _certificateRepository.GetCertificateIncludeLinksAsync(certificateId,
                                                                                       userId,
                                                                                       cancellationToken);

        if (certificate is null)
        {
            return(null);
        }

        return(new LinkListViewModel
        {
            CertificateId = certificateId,
            Links = certificate.Links.Select(e =>
            {
                var link = new LinkViewModel
                {
                    Id = e.Id,
                    Url = e.Url,
                    CertificateId = e.CertificateId
                };

                return link;
            })
        });
    }
Beispiel #9
0
        public static LinkViewModel Initialize(this LinkViewModel model, AnimangaLink link)
        {
            model.Text = link.Text;
            model.Href = link.Href;

            return(model);
        }
Beispiel #10
0
 public void StartConnection(object sender, MouseButtonEventArgs e)
 {
     ViewUtils.FindFocusableParent(this)?.Focus();
     if (ViewModel == null)
     {
         return;
     }
     CaptureMouse();
     LostMouseCapture += StopConnection;
     MouseUp          += StopConnection;
     MouseMove        += UpdateConnection;
     _newLink          = new LinkViewModel(ViewModel.Node.Script, new PositionedViewModelBase
     {
         Position = new Point(ViewModel.Position.X + ViewModel.Size.Width,
                              ViewModel.Position.Y + ViewModel.Size.Height / 2)
     }, new PositionedViewModelBase
     {
         Position = new Point(ViewModel.Position.X, ViewModel.Position.Y + ViewModel.Size.Height / 2)
     }
                                           , null,
                                           ViewModel.IsExecutionPin)
     {
         IsSelected = true
     };
     ViewModel.Node.Script.Items.Add(_newLink);
     ViewModel.StartConnection();
     e.Handled = true;
 }
Beispiel #11
0
        public async Task <IActionResult> OnGetAsync(Guid id)
        {
            var link = await _linksService.GetAll().Include(l => l.Webpage).FirstOrDefaultAsync(l => l.Id == id);

            if (link == null)
            {
                return(NotFound());
            }
            ViewData["LinkId"] = link.Id;
            ViewData["PageId"] = link.Webpage.Id;

            NameDisplay = await TranslationsService.TranslateAsync("name");

            PageTitle = await TranslationsService.TranslateAsync("Update link");

            LinkNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay);
            LinkNameLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString());
            LinkUrlRequiredError  = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field 'Url' must contain a minimum of {4} and a maximum of {200} characters.", "Url", 4.ToString(), 200.ToString());

            Vm = new LinkViewModel
            {
                LinkId = link.Id.ToString(),
                PageId = link.Webpage.Id,
                Name   = link?.Name,
                Url    = link.Url
            };

            return(Page());
        }
        public JsonApplication Applist()
        {
            List <LinkViewModel> linklistobj     = new List <LinkViewModel>();
            JsonApplication      jsonApplication = new JsonApplication();

            try
            {
                var App = _links.ApplicationCategory();
                foreach (var item in App)
                {
                    LinkViewModel linkOBJ = new LinkViewModel();
                    linkOBJ.Name = item.Title;
                    linkOBJ.Icon = item.Icon;
                    linkOBJ.UrL  = item.Url;
                    linklistobj.Add(linkOBJ);
                }
                jsonApplication.Result = linklistobj;
                return(jsonApplication);
            }
            catch (Exception ex)
            {
                string Mes = ex.Message;
                return(jsonApplication);
            }
        }
Beispiel #13
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     selectedGroup     = e.Parameter as Group;
     _linkViewModel    = new LinkViewModel(selectedGroup);
     DataContext       = _linkViewModel;
     txtGroupName.Text = selectedGroup.Name;
 }
Beispiel #14
0
        public LinkViewModel All(ApiCall call)
        {
            LinkViewModel model = new LinkViewModel();

            var allpageroutes = call.WebSite.SiteDb().Routes.GetByType(ConstObjectType.Page);

            foreach (var item in allpageroutes)
            {
                if (item.objectId != default(Guid))
                {
                    LinkItem linkitem = new LinkItem();
                    linkitem.Url        = item.Name;
                    linkitem.Parameters = item.Parameters.Keys.ToList();
                    model.Pages.Add(linkitem);
                }
            }

            var allviews = call.WebSite.SiteDb().Views.All();

            foreach (var item in allviews)
            {
                LinkItem linkitem = new LinkItem();
                linkitem.Url = ObjectService.GetObjectRelativeUrl(call.WebSite.SiteDb(), item);
                //  linkitem.Parameters = Sites.Routing.PageRoute.GetViewParameters(call.SiteDb, item.Id);
                model.Views.Add(linkitem);
            }

            return(model);
        }
Beispiel #15
0
        /// <summary>
        /// Restituisce la trasformazione dell'asse lineare (inteso come asse non rotativo, lineare o pneumatico)
        /// </summary>
        /// <param name="link"></param>
        /// <returns></returns>
        private Transform3D CreateLinearTRandormation3D(LinkViewModel link)
        {
            Action <double> action    = null;
            var             tt        = new TranslateTransform3D();
            var             offset    = (link is LinearLinkViewModel linearLink) ? linearLink.Pos : 0.0;
            var             direction = link.Direction;

            switch (direction)
            {
            case LinkDirection.X:
                tt.OffsetX = link.Value - offset;
                action     = (d) => tt.OffsetX = d - offset;
                break;

            case LinkDirection.Y:
                tt.OffsetY = link.Value - offset;
                action     = (d) => tt.OffsetY = d - offset;
                break;

            case LinkDirection.Z:
                tt.OffsetZ = link.Value - offset;
                action     = (d) => tt.OffsetZ = d - offset;
                break;

            default:
                throw new ArgumentException("Invalid traslation direction!");
            }


            link.ValueChanged += (s, e) => action(e);

            return(tt);
        }
Beispiel #16
0
        public ActionResult ExcluirQuest(LinkViewModel model)
        {
            int Id;

            if (int.TryParse(Util.Decrypt(model.Hash), out Id))
            {
                var quest = db.Quest.Find(Id);

                if (!User.Identity.HasQuest(model.Hash))
                {
                    TempData["Alerta"] = "Você não pode executar esta ação";
                    TempData["Classe"] = "yellow-alert";
                }
                else
                {
                    db.Quest.Remove(quest);
                    db.SaveChanges();

                    TempData["Alerta"] = "Excluído com sucesso";
                    TempData["Classe"] = "green-alert";
                }
            }
            else
            {
                TempData["Alerta"] = "Algo deu errado";
                TempData["Classe"] = "yellow-alert";
            }

            return(RedirectToAction("Inicio", "Home"));
        }
Beispiel #17
0
    public async Task <bool> CreateLinkAsync(LinkViewModel lvm,
                                             string userId,
                                             CancellationToken cancellationToken = default)
    {
        var certificate = await _certificateRepository.GetCertificateIncludeLinksAsync(lvm.CertificateId,
                                                                                       userId,
                                                                                       cancellationToken);

        if (certificate != null)
        {
            // Check the limit (maximum 5).
            if (certificate.Links.Count >= 5)
            {
                return(true);
            }

            await _linkRepository.CreateAsync(new Link(lvm.Url, lvm.CertificateId),
                                              cancellationToken);

            await _cacheService.SetItemAsync(lvm.CertificateId, userId);

            return(true);
        }

        return(false);
    }
Beispiel #18
0
        public Transform3D CreateTranslation3D(Matrix matrix, LinkViewModel link)
        {
            var tg = new Transform3DGroup();
            var st = CreateTransformation3D(matrix);

            //var tt = new TranslateTransform3D();

            tg.Children.Add(st);
            //tg.Children.Add(tt);

            //Action<double> action = (d) => tt.OffsetX = d;
            //link.ValueChanged += (s, e) => action(e);

            switch (link.Type)
            {
            case Data.Enums.LinkType.Linear:
                tg.Children.Add(CreateLinearTRandormation3D(link));
                break;

            case Data.Enums.LinkType.Rotary:
                tg.Children.Add(CreateRotaryTransformation3D(link, st.Transform(new Point3D())));
                break;

            default:
                throw new ArgumentException();
            }


            return(tg);
        }
Beispiel #19
0
        private async Task InitializeViewModel(LinkViewModel vm, LinkResponse link)
        {
            var domain = HostContext.AppSettings.GetString("Domain");

            if (domain.IsNullOrEmpty())
            {
                domain = new Uri(Request.GetDisplayUrl()).GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
            }

            vm.ShortUrl = $"{domain.AppendPath(link.Key)}";

            if (vm.ScreenshotUrl.IsNullOrEmpty())
            {
                vm.IsScreenshotReady = false;
                vm.ScreenshotUrl     = HostContext.AppSettings.GetString("DefaultScreenshotPlaceholder");
            }
            else
            {
                vm.IsScreenshotReady = true;
            }

            var tags = await Gateway.SendAsync(new GetTagsRequest()
            {
            });

            vm.Tags = tags.Select(m =>
            {
                var t        = m.ConvertTo <TagViewModel>();
                t.IsSelected = vm.Tags?.FirstOrDefault(r => r.Key == m.Key)?.IsSelected ?? link?.Tags?.Contains(m.Key) ?? false;

                return(t);
            })
                      .Where(m => m.IsSelected) // for this VM, we only care about SELECTED tags
                      .ToList();
        }
Beispiel #20
0
        public LinkViewModel UpdateLink(LinkViewModel model)
        {
            var entity = model.ToEntity();

            _repository.Update(entity);
            _context.SaveChanges();
            return(model);
        }
Beispiel #21
0
 public object CreateTranslation(Matrix matrix, LinkViewModel link)
 {
     if (link == null)
     {
         return(CreateTransformation3D(matrix));
     }
     else
     {
         return(CreateTranslation3D(matrix, link));
     }
 }
Beispiel #22
0
        public LinkViewModel SaveLink(LinkViewModel model)
        {
            var entity = model.ToEntity();

            entity.LinkID     = SequenceQueue.NewIdGuid();
            entity.CreateDate = DateTime.Now;
            entity.IsImage    = model.IsImage;
            _repository.AddAsync(entity);
            _context.SaveChanges();
            return(model);
        }
 public IHttpActionResult EditLink(LinkViewModel model)
 {
     try
     {
         var result = LinksService.EditLink(model, User.Identity.GetUserId());
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        [HttpPost]                          // POST api/links
        public async Task <ActionResult <LinkViewModel> > CreateLink([FromBody] LinkViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(base.BadRequest());
            }


            await(_repoWrapper.Links.AddModel(viewModel));

            return(base.CreatedAtRoute(nameof(GetLink), new { id = viewModel.Id }, viewModel));
        }
Beispiel #25
0
        public void UpdateLink(LinkViewModel model)
        {
            Link tempLink = new Link()
            {
                Id         = Guid.Parse(model.Id),
                CutLink    = model.CutLink,
                CreateTime = model.CreateTime,
                ViewCount  = model.ViewCount
            };

            Db.UpdateLink(tempLink);
        }
Beispiel #26
0
        public ActionResult ExcluirGrupo(LinkViewModel model)
        {
            if (ModelState.IsValid)
            {
                int Id;
                if (int.TryParse(Util.Decrypt(model.Hash), out Id))
                {
                    Grupo grupo = db.Grupo.Find(Id);
                    if (!User.Identity.IsAdm(grupo.Id))
                    {
                        TempData["Classe"] = "yellow-alert";
                        TempData["Alerta"] = "Você não tem permissão para executar essa ação";
                        return(RedirectToAction("Inicio", "Home"));
                    }

                    foreach (var usu in grupo.Users)
                    {
                        var user = User as ClaimsPrincipal;
                    }

                    db.Grupo.Remove(grupo);

                    foreach (var user in grupo.Users)
                    {
                        foreach (var claim in user.Claims.ToList())
                        {
                            if (claim.ClaimType == "Adm")
                            {
                                db.Entry(claim).State = System.Data.Entity.EntityState.Deleted;
                            }
                        }
                    }

                    db.SaveChanges();

                    TempData["Classe"] = "green-alert";
                    TempData["Alerta"] = "Removido com sucesso";
                }
                else
                {
                    TempData["Alerta"] = "Algo deu errado";
                    TempData["Classe"] = "yellow-alert";
                }
            }
            else
            {
                TempData["Alerta"] = "Algo deu errado";
                TempData["Classe"] = "yellow-alert";
            }

            return(RedirectToAction("Inicio", "Home"));
        }
Beispiel #27
0
        public ActionResult PremiumCancelar(LinkViewModel model)
        {
            int Id;

            if (int.TryParse(Util.Decrypt(model.Hash), out Id))
            {
                return(View(new Tuple <string>(model.Hash)));
            }

            TempData["Alerta"] = "Algo deu errado";
            TempData["Classe"] = "yellow-alert";
            return(RedirectToAction("Inicio", "Home"));
        }
        public async Task <MainNavigationViewModel> BuildModelAsync(ComponentModelBase componentModel)
        {
            var links = new List <LinkViewModel>
            {
                new LinkViewModel
                {
                    Text = this.globalLocalizer.GetString("Home"),
                    Url  = this.linkGenerator.GetPathByAction("Index", "Home", new { Area = "Home", culture = CultureInfo.CurrentUICulture.Name })
                }
            };

            if (componentModel.IsAuthenticated)
            {
                links.Add(new LinkViewModel
                {
                    Text = this.orderLocalizer.GetString("MyOrders").Value,
                    Url  = this.linkGenerator.GetPathByAction("Index", "Orders", new { Area = "Orders", culture = CultureInfo.CurrentUICulture.Name })
                });

                links.Add(new LinkViewModel
                {
                    Text = this.orderLocalizer.GetString("PlaceOrder").Value,
                    Url  = this.linkGenerator.GetPathByAction("Index", "Order", new { Area = "Orders", culture = CultureInfo.CurrentUICulture.Name })
                });
            }

            links.Add(new LinkViewModel
            {
                Text = this.globalLocalizer.GetString("AvailableProducts"),
                Url  = this.linkGenerator.GetPathByAction("Index", "AvailableProducts", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name })
            });

            if (!this.configuration.Value.IsMarketplace)
            {
                var brand = await this.brandRepository.GetBrandAsync(this.configuration.Value.OrganisationId, componentModel.Token, componentModel.Language);

                var brandZoneLink = new LinkViewModel
                {
                    Text = this.globalLocalizer.GetString("Products").Value,
                    Url  = this.linkGenerator.GetPathByAction("Index", "Brand", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name, Id = this.configuration.Value.OrganisationId })
                };

                links.Add(brandZoneLink);
            }

            return(new MainNavigationViewModel
            {
                Links = links
            });
        }
Beispiel #29
0
        public IActionResult Edit(long id)
        {
            var           link   = linkService.GetLink(id);
            LinkViewModel linkVM = new LinkViewModel();

            linkVM.Name        = link.Name;
            linkVM.Url         = link.Url;
            linkVM.IsVisible   = link.IsVisible;
            linkVM.Description = link.Description;
            linkVM.Target      = link.Target;


            return(View(linkVM));
        }
Beispiel #30
0
 public ActionResult Index(LinkViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (User.Identity.HasQuest(model.Hash))
         {
             int Id;
             if (int.TryParse(Util.Decrypt(model.Hash), out Id))
             {
                 var quest = db.Quest.Find(Id);
                 if (quest.UsuarioCriadorId == User.Identity.GetUserId <int>() || User.Identity.IsAdm(quest.GrupoCriador.Id))
                 {
                     return(View("QuestAdm", new QuestInfoViewModel()
                     {
                         HasGroup = quest.GrupoCriadorId != null,
                         QuestId = Util.Encrypt(quest.Id.ToString()),
                         Colaboradores = (quest.GrupoCriadorId != null) ? quest.GrupoCriador.Users.ToList() : null
                     }));
                 }
                 else
                 {
                     return(View("Quest", new QuestInfoViewModel()
                     {
                         HasGroup = quest.GrupoCriadorId != null,
                         QuestId = Util.Encrypt(quest.Id.ToString())
                     }));
                 }
             }
             else
             {
                 TempData["Alerta"] = "Algo deu errado";
                 TempData["Classe"] = "yellow-alert";
                 return(RedirectToAction("Inicio", "Home"));
             }
         }
         else
         {
             TempData["Alerta"] = "Você não pode entrar nesta página";
             TempData["Classe"] = "yellow-alert";
             return(RedirectToAction("Inicio", "Home"));
         }
     }
     else
     {
         TempData["Alerta"] = "Formulário inválido";
         TempData["Classe"] = "yellow-alert";
         return(RedirectToAction("Inicio", "Home"));
     }
 }
        public async Task <Result> Delete(LinkViewModel model)
        {
            try
            {
                return(ModelState.IsValid
                    ? await _repository.Delete(LinkViewModel.Get(model))
                    : Result.Failed);
            }
            catch (Exception e)
            {
                await _logger.AddException(e);

                return(Result.Failed);
            }
        }
        public ActionResult GetLinks(int? max)
        {
            List<Link> links = RoadNetwork.Instance.NetworkModel.GetAllLinks();
            if (max.HasValue && max <= links.Count)
            {
                links = links.GetRange(0, max.Value);
            }

            GetLinksViewModel vm = new GetLinksViewModel();
            vm.Links = new List<LinkViewModel>();
            foreach (Link l in links)
            {
                LinkViewModel lvm = new LinkViewModel();
                //lvm.Polyline = l.PolylineLatLon;
                lvm.Length = l.Length;
                lvm.Attributes = l.Attributes;
                lvm.Polyline = l.PolylineNorEst;
                vm.Links.Add(lvm);
            }

            return Json(vm);
        }
        public LinkOptionsWindow(AmoebaManager amoebaManager)
        {
            _amoebaManager = amoebaManager;

            InitializeComponent();

            try
            {
                foreach (var item in Settings.Instance.LinkOptionsWindow_DownloadLinkItems)
                {
                    var viewModel = new LinkViewModel();
                    viewModel.Signature = item.Signature;
                    viewModel.TrustSignatures.AddRange(item.TrustSignatures);

                    _downloadCollection.Add(viewModel);
                }

                foreach (var item in Settings.Instance.LinkOptionsWindow_UploadLinkItems)
                {
                    var viewModel = new LinkViewModel();
                    viewModel.Signature = item.Signature;
                    viewModel.TrustSignatures.AddRange(item.TrustSignatures);

                    _uploadCollection.Add(viewModel);
                }
            }
            catch (Exception)
            {
                throw;
            }

            _downloadLinkListView.ItemsSource = _downloadCollection;
            _uploadLinkListView.ItemsSource = _uploadCollection;

            this.Sort();
        }
		public SelfViewModel(LinkViewModel selfLink)
		{
			_selfLink = selfLink;
            UIThreadLoad = true;
		}
        private void _uploadLinkListViewNemMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SignatureWindow window = new SignatureWindow();
            window.Owner = this;

            if (window.ShowDialog() == true)
            {
                var signature = window.DigitalSignature.ToString();

                var item = new LinkViewModel()
                {
                    Signature = signature,
                };

                if (_uploadCollection.Any(n => n.Signature == signature)) return;
                _uploadCollection.Add(item);
            }
        }
        private void _downloadLinkListViewPasteMenuItem_Click(object sender, RoutedEventArgs e)
        {
            foreach (var signature in Clipboard.GetText().Split('\r', '\n'))
            {
                if (!Signature.Check(signature)) continue;

                var item = new LinkViewModel()
                {
                    Signature = signature,
                };

                if (_downloadCollection.Any(n => n.Signature == signature)) continue;
                _downloadCollection.Add(item);
            }
        }