Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ShortUrlRepository das = new ShortUrlRepository();
            string             str = Console.ReadLine();

            Console.WriteLine(das.lengthenUrl(str));
        }
Exemplo n.º 2
0
 public JsonResult <string> LengthenUrl(string url)
 {
     try
     {
         ShortUrlRepository dal = new ShortUrlRepository();
         var fullUrl            = dal.lengthenUrl(url);
         return(Json <string>(fullUrl));
     }
     catch (Exception ex)
     {
         var response = new HttpResponseMessage(HttpStatusCode.GatewayTimeout)
         {
             Content    = new StringContent("Unable to connect to database", System.Text.Encoding.UTF8, "text/plain"),
             StatusCode = HttpStatusCode.GatewayTimeout
         };
         throw new HttpResponseException(response);
     }
 }