Commit 4c3a8add authored by Francisco Iván García Torres's avatar Francisco Iván García Torres

Merge branch 'feature/languageData' into 'master'

Feature/language data

See merge request !2
parents 7b057aad 45b2c379
......@@ -35,6 +35,7 @@
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -45,10 +46,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="JsonTranslator.cs" />
<Compile Include="Languages.cs" />
<Compile Include="Models\Language.cs" />
<Compile Include="Traductor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add name="connectionStringSomee"
connectionString="
metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;data source=languagesDat.mssql.somee.com;initial catalog=list;packet size=4096;persist security info=False;user id=torgaiv3_SQLLogin_1;pwd=nz53hhpc22;MultipleActiveResultSets=True&quot;"
providerName="System.Data.EntityClient" />
</configuration>
\ No newline at end of file
using Api.Business.Models;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
namespace Api.Business
{
public static class Languages
{
public static ICollection<Language> getAllLanguages()
{
ICollection<Language> response = null;
string connectionString = "Server = languagesDat.mssql.somee.com; Database = languagesDat; User ID = torgaiv3_SQLLogin_1; Password = nz53hhpc22; Trusted_Connection = False;";
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM list", cn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
response = new List<Language>();
while (dr.Read())
{
response.Add(new Language()
{
LanguageCode = Convert.ToString(dr["id"]),
LanguageDescription = Convert.ToString(dr["value"])
});
}
}
}
return response;
}
}
}
using System;
namespace Api.Business.Models
{
[Serializable]
public class Language
{
public string LanguageCode { get; set; }
public string LanguageDescription { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace Api.Business
......@@ -13,7 +14,7 @@ namespace Api.Business
string TrimValue = @"<div dir=""ltr"" class=""t0"">";
int getTranslatedString = Aresult.IndexOf(TrimValue) + TrimValue.Length;
string getTranslatedFullString = Aresult.Substring(getTranslatedString);
if (getTranslatedFullString.Contains("\\"))
{
if (getTranslatedFullString.Contains("\\x26#39;"))
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
# Visual Studio 15
VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.Traductor", "Api.Traductor\Api.Traductor.csproj", "{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}"
EndProject
......@@ -10,17 +10,57 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|ARM.ActiveCfg = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|ARM.Build.0 = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|ARM64.Build.0 = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|x64.Build.0 = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|x86.ActiveCfg = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Debug|x86.Build.0 = Debug|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|Any CPU.Build.0 = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|ARM.ActiveCfg = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|ARM.Build.0 = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|ARM64.ActiveCfg = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|ARM64.Build.0 = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|x64.ActiveCfg = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|x64.Build.0 = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|x86.ActiveCfg = Release|Any CPU
{13A0F83E-E73A-41EA-BB01-57D4C80EC9C5}.Release|x86.Build.0 = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|ARM.Build.0 = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|ARM64.Build.0 = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|x64.ActiveCfg = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|x64.Build.0 = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Debug|x86.Build.0 = Debug|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|Any CPU.Build.0 = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|ARM.ActiveCfg = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|ARM.Build.0 = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|ARM64.ActiveCfg = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|ARM64.Build.0 = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|x64.ActiveCfg = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|x64.Build.0 = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|x86.ActiveCfg = Release|Any CPU
{5BE36FE7-FD73-4448-8451-5C91D01A8691}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -44,6 +44,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
......
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Web.Services;
namespace Api.Traductor
......@@ -9,7 +9,6 @@ namespace Api.Traductor
public class ServicioRest : System.Web.Services.WebService
{
[WebMethod]
public string Translate(string input, string langFrom, string langTo)
{
......@@ -34,7 +33,13 @@ namespace Api.Traductor
throw new System.Exception("El campo lenguaje destino no puede estar vacío");
return Api.Business.JsonTranslator.TranslateJson(input, langFrom, langTo);
}
[WebMethod]
public string getAllLanguages()
{
var jsonSerialiser = new JavaScriptSerializer();
return jsonSerialiser.Serialize(Api.Business.Languages.getAllLanguages());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net452" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment