public async Task <Link> AddLinkAsync(string FullUrl, string ownerId) { Link old_link = await Links.OrderBy(l => l.Number).LastOrDefaultAsync(); int new_num = old_link is null ? 1 : (old_link.Number + 1); string id = StringGenerator.getString(new_num); Link link = new Link { Id = id, Number = new_num, FullUrl = FullUrl, Clicks = new List <Click>(), OwnerId = ownerId }; await Links.AddAsync(link); return(link); }