Exemplo n.º 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();
     }
 }
 partial void UpdateLink(Link instance);
 partial void DeleteLink(Link instance);
 partial void InsertLink(Link instance);