NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using translator.Models;
using translator.Constants;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using System.Net.Http;
using System.Text.Json;
using Newtonsoft.Json;
using Microsoft.Extensions.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Antiforgery;
using translator.AntiForgeryToken;
using Ganss.Xss;
using System;
using System.Text;
using System.Web.Http.Results;
using AngleSharp.Io;

namespace contentFactory.Controllers
{
//[Route("4077/translator/api/[controller]")]
[Route("api/[controller]")]
[Produces("application/json")]
[ApiController]
public class TranslatorController : ControllerBase
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IAntiforgery antiforgery;
private readonly IHttpContextAccessor _httpContext;
private readonly string Session_Key;
/*private readonly bool isCheckAKSUserID = false;*/
private string ApiBaseUrl;
private string SitBaseUrl;
private string DevBaseUrl;
private string BaseUatUrl;
private string BasePtUrl;
private string BaseProdUrl;
private string HostUrl;
private static string? AksId;


public TranslatorController(IHttpClientFactory httpClientFactory, IConfiguration configuration, IAntiforgery iantiforgery)
{

_httpClientFactory = httpClientFactory;
antiforgery = iantiforgery;
ApiBaseUrl = configuration["ApiUrl"];
DevBaseUrl = configuration["BaseDevUrl"];
SitBaseUrl = configuration["BaseSitUrl"];
BaseUatUrl = configuration["BaseUatUrl"];
BasePtUrl = configuration["BasePtUrl"];
BaseProdUrl = configuration["BaseProdUrl"];


}

[HttpPost("text-translation")]
[ValidateHeaderAntiForgeryToken]
public async Task<string> postUserData(translatorInputModel dataModel)
{
using (var client = _httpClientFactory.CreateClient())
{
var req = Request.Host.ToString();
if (req.Contains("onecdev"))
{
HostUrl = DevBaseUrl;
}
else if (req.Contains("onecsit"))
{
HostUrl = SitBaseUrl;
}
else if (req.Contains("onecuat"))
{
HostUrl = BaseUatUrl;
}
else if (req.Contains("onecpt"))
{
HostUrl = BasePtUrl;
}
else if (req.Contains("onecognizant"))
{
HostUrl = BaseProdUrl;
}
else
{
HostUrl = ApiBaseUrl;
}

if (req.Contains("localhost") || req.Contains("onecpt"))
{
var sanitizeValue = new HtmlSanitizer();
AksId = sanitizeValue.Sanitize("<script>alert('xss')</script>560457");

}
else
{
// if (string.IsNullOrEmpty(Request.Headers[AppConstants.AKSUserId]))
// {
var sanitizeValue = new HtmlSanitizer();
string headerID = Request.Headers[AppConstants.AKSUserId].ToString();

AksId = sanitizeValue.Sanitize(headerID);
// }

}

if (!req.Contains("onecpt"))
{
dataModel.emp_id = AksId;
}
HttpResponseMessage response = await client.PostAsJsonAsync($"{HostUrl}{AppConstants.translatorTextApiRoute}", dataModel);
var result = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode == true)
{
return result;
}
else
{
throw new ApplicationException(result);
}

}
}

[HttpPost("document-translation")]
[ValidateHeaderAntiForgeryToken]
public async Task<string> postUserData(translatorDocInputModel dataModel)
{
using (var client = _httpClientFactory.CreateClient())
{
var req = Request.Host.ToString();
if (req.Contains("onecdev"))
{
HostUrl = DevBaseUrl;
}
else if (req.Contains("onecsit"))
{
HostUrl = SitBaseUrl;
}
else if (req.Contains("onecuat"))
{
HostUrl = BaseUatUrl;
}
else if (req.Contains("onecpt"))
{
HostUrl = BasePtUrl;
}
else if (req.Contains("onecognizant"))
{
HostUrl = BaseProdUrl;
}
else
{
HostUrl = ApiBaseUrl;
}

if (req.Contains("localhost") || req.Contains("onecpt"))
{
var sanitizeValue = new HtmlSanitizer();
AksId = sanitizeValue.Sanitize("<script>alert('xss')</script>560457");

}
else
{
// if (string.IsNullOrEmpty(Request.Headers[AppConstants.AKSUserId]))
// {
var sanitizeValue = new HtmlSanitizer();
string headerID = Request.Headers[AppConstants.AKSUserId].ToString();

AksId = sanitizeValue.Sanitize(headerID);
// }

}

if (!req.Contains("onecpt"))
{
dataModel.emp_id = AksId;
}
HttpResponseMessage response = await client.PostAsJsonAsync($"{HostUrl}{AppConstants.translatorDocApiRoute}", dataModel);

var result = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode == true)
{
return result;
}
else
{
throw new ApplicationException(result);
}
}

}

[HttpGet("AKSuser")]
public string GetUserID()
{
string _user = string.Empty;
var req = Request.Host.ToString();
if (req.Contains("localhost") || req.Contains("onecpt"))
{
var sanitizeValue = new HtmlSanitizer();
_user = sanitizeValue.Sanitize("<script>alert('xss')</script>560457");
AksId = _user;
return "560457";

}
else
{
if (!string.IsNullOrEmpty(Request.Headers[AppConstants.AKSUserId]))
{
var sanitizeValue = new HtmlSanitizer();
string headerID = Request.Headers[AppConstants.AKSUserId].ToString();

_user = sanitizeValue.Sanitize(headerID);
AksId = _user;
}
return _user;
}
}

[HttpGet("GetLiveStatus")]
public string GetLiveStatus()
{
return "API is working";
}

}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.