public Url Shorten(string original, string userId, LinkExpiration duration) { Url url = new Url(userId, original, duration); string generated = _parameterService.GenerateNextValue(ParameterConstants.LastCreated).Value; while (!_repository.CheckAvailable(generated)) { generated = _parameterService.GenerateNextValue(ParameterConstants.LastCreated).Value; } url.ChangeShortened(generated); _repository.Add(url); return(url); }
public Url Edit(string userId, string shortened, string newShortened, LinkExpiration duration) { Url url = Get(userId, shortened); if (url == null) { return(null); } if (_repository.CheckAvailable(newShortened)) { url.Edit(newShortened, duration); } else { url.Edit(url.Shortened, duration); } _repository.Update(url); return(url); }
public Url(string userId, string originalUrl, string shortened, LinkExpiration duration) : this(userId, originalUrl, duration) => Shortened = shortened;
public Url(string userId, string originalUrl, LinkExpiration expiration) { UserId = userId; OriginalUrl = originalUrl; Expiration = expiration; }