コード例 #1
0
 /// <summary>
 /// Creates a link in the database based on the IPAddress of the requestor and the RedirectUrl
 /// </summary>
 /// <param name="ipAddress"></param>
 /// <param name="redirectUrl"></param>
 /// <returns></returns>
 public static string AddLink(string ipAddress, string redirectUrl)
 {
     try
     {
         DbContext dbContext = new DbContext();
         var newLink = new Link();
         newLink.Id = Guid.NewGuid();
         newLink.DateCreated = DateTime.Now;
         newLink.RedirectUrl = redirectUrl;
         newLink.ShortCode = CreateUnusedShortCode();
         newLink.VisitCount = 0;
         dbContext.Links.InsertOnSubmit(newLink);
         dbContext.SubmitChanges();
         return newLink.ShortCode;
     }
     catch
     {
         throw new Exception();
     }
 }
コード例 #2
0
 partial void UpdateLink(Link instance);
コード例 #3
0
 partial void DeleteLink(Link instance);
コード例 #4
0
 partial void InsertLink(Link instance);