https://learn.microsoft.com/en-us/aspnet/core/fund...
public interface IWriteToDBService
{
public void WriteOccurrencesData(OccurrencesData data);
}
public class WriteToDBService : IWriteToDBService
{
private readonly WebApiContext _context;
public void WriteOccurrencesData(OccurrencesData data)
{
_context.OccurrencesData.AddAsync(data);
_context.SaveChanges();
}
public WriteToDBService(WebApiContext context)
{
_context = context;
}
}
public class OccurrenceСounter
{
private readonly WriteToDBService writeToDB;
public OccurrenceСounter(WriteToDBService writeToDB)
{
this.writeToDB = writeToDB;
}
public async Task<OccurrencesData> CollectOccurrences(VKUsersPosts posts)
{
await WriteStartLog();
OccurrencesData result = new(posts.response.items[0].owner_id.ToString());
for (int j = 0; j < 5; j++)
{
for (int i = 0; i < 32; i++)
{
if (i == 6) result.Data[j].Add('ё', 0);
result.Data[j].Add((char)(1072 + i), 0);
}
}
for (int j = 0; j < 5; j++)
{
string text = posts.response.items[j].text;
RemoveSalt( ref text );
FindOccurrences(ref result.Data[j], text );
}
await WriteEndLog();
result.UpdateJsonString();
writeToDB.WriteOccurrencesData(result);
return result;
}
}
public class HomeController : Controller
{
private WebApiContext Context { get; set; }
public HomeController(WebApiContext context)
{
Context = context;
}
[HttpGet("{ind}")]
public async Task< IActionResult> JsonString(int ind)
{
GetterData getter = new GetterData();
VKUsersPosts posts = await getter.GetLast5Posts("738489146");
OccurrenceСounter сounter2 = new(new(Context));
OccurrencesData dicts = await сounter2.CollectOccurrences(posts);
try
{
return Ok( JsonSerializer.Deserialize(dicts.JsonString, typeof(Dictionary<char, int>[])));
}
catch
{
return NotFound();
}
}
}
@page
@model WebApplication1.Pages.CreateModel
@{
if (Request.Method == "POST") {
string text = Request.Form["test"];
<text>
You entered: @text
</text>
}
}
<head>
<title>Customer Form</title>
</head>
<body>
<form method="post" >
<fieldset>
<div>
<input type="text" value="" name="test"/>
</div>
<div>
<label> </label>
<input type="submit" value="Submit" class="submit" />
</div>
</fieldset>
</form>
</body>
Я нашел блейзер только в браузере(конфигурация приложения):
и в сервере: