/// <summary> /// Make Short Url /// </summary> /// <param name="requestData">Url Shortening request dto</param> /// <returns>Url Shortening response dto</returns> public async Task <UrlShorteningResponse> MakeShortUrl(UrlShorteningRequest requestData) { // Generate unique short code of 7 characters string shortCode = await GenerateUniqueShortCode(7); // Save short url and long url data in database bool isCreated = await urlService.CreateUrlDataAsync(new Domain.tbl_urldata { ShortUrl = shortCode, LongUrl = requestData.url, NumberOfTimes = requestData.numberOfTimes, ExpireDate = requestData.expireDate, Status = (byte)Enum.UrlStatus.Active, CreateDate = DateTime.UtcNow }); // Make the response return(new UrlShorteningResponse { shortUrl = this.shortUrl + shortCode, longUrl = requestData.url }); }