Example #1
0
        public LinkModel Save(LinkModel link)
        {
            var links = Retrive();
            var maxID = links.Max(p => p.Id);

            link.Id = maxID + 1;
            links.Add(link);
            WriteData(links);
            return(link);
        }
Example #2
0
        public LinkModel Delete(int id, LinkModel link)
        {
            var links = Retrive();
            var index = links.FindIndex(l => l.Id == id);

            if (index >= 0)
            {
                links.RemoveAt(index);
                WriteData(links);
            }
            else
            {
                return(null);
            }
            return(link);
        }
Example #3
0
        public LinkModel Save(int id, LinkModel link)
        {
            var links = Retrive();
            var index = links.FindIndex(l => l.Id == id);

            if (index >= 0)
            {
                links[index] = link;
                WriteData(links);
            }
            else
            {
                return(null);
            }
            return(link);
        }