public ShortUrl CreateShortUrl(ShortUrl shortUrl) { return ShortUrlOperations.CreateShortUrl(shortUrl); }
public void UpdateShortUrl(ShortUrl shortUrl) { ShortUrlOperations.UpdateShortUrl(shortUrl); }
public ShortUrl AddShortUrl(ShortUrl shortUrl) { return ShortUrlOperations.AddShortUrl(shortUrl); }
internal void UpdateShortUrl(ShortUrl shortUrl) { shortUrl.ObjectState = ObjectState.Modified; this.unitOfWork.Repository<ShortUrl>().Update(shortUrl); }
internal ShortUrl CreateShortUrl(ShortUrl shortUrl) { shortUrl.ObjectState = ObjectState.Added; this.unitOfWork.Repository<ShortUrl>().Insert(shortUrl); return shortUrl; }
internal ShortUrl AddShortUrl(ShortUrl shortUrl) { this.unitOfWork.Repository<ShortUrl>().Insert(shortUrl); return shortUrl; }
/// <summary> /// Generate and add a short url from a passed long url. /// <param name="longUrl">A long url to be shortened.</param> /// <returns>Returns a shortUrlId string.</returns> /// </summary> internal string AddShortUrl(string longUrl) { if (!String.IsNullOrEmpty(longUrl)) { // Populate a new ShortUrl object. ShortUrl newShortUrl = new ShortUrl(); // Populate the remaining properties. newShortUrl.ShortUrlId = Security.GenerateRandomString(6); // 44,261,653,680 Permutations. newShortUrl.LongUrl = longUrl; newShortUrl.DateCreated = DateTime.UtcNow; // Add the new short url and log the event. // An exception will be thrown if the key already exists. 1 in 44 billion chance and users will just request it again. this.doctrineShipsRepository.CreateShortUrl(newShortUrl); this.doctrineShipsRepository.Save(); logger.LogMessage("Short Url '" + newShortUrl.ShortUrlId + "' Generated.", 2, "Message", MethodBase.GetCurrentMethod().Name); // Return the value. return newShortUrl.ShortUrlId; } else { return "Error"; } }