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); }
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); }
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); }