Exemple #1
0
        public IActionResult EditLink([FromBody] RequestLinkData linkItem)
        {
            var linksJsonData = System.IO.File.ReadAllText(linksFilePath);

            var linksData = JsonConvert.DeserializeObject <List <GroupItem> >(linksJsonData);

            var group = linksData.FirstOrDefault(g => g.GroupId == linkItem.GroupId);

            var link = group.Links.FirstOrDefault(l => l.LinkId == linkItem.LinkId);

            link.Name        = linkItem.Name;
            link.Url         = linkItem.Url;
            link.Description = linkItem.Description;

            SaveLinkData(linksData);

            return(Ok());
        }
Exemple #2
0
        public IActionResult AddLink([FromBody] RequestLinkData linkItem)
        {
            var linksJsonData = System.IO.File.ReadAllText(linksFilePath);

            var linksData = JsonConvert.DeserializeObject <List <GroupItem> >(linksJsonData);

            var group       = linksData.FirstOrDefault(g => g.GroupId == linkItem.GroupId);
            var newLinkItem = new LinkItem {
                Name        = linkItem.Name,
                Description = linkItem.Description,
                Url         = linkItem.Url,
                LinkId      = Guid.NewGuid()
            };

            group.Links.Add(newLinkItem);

            SaveLinkData(linksData);

            return(Ok());
        }