mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 19:04:12 +02:00
setting up logging in controller
This commit is contained in:
@@ -75,23 +75,34 @@ namespace yaflay.ru.Новая_папка
|
|||||||
JsonNode response = JsonNode.Parse(responseBody);
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
if (response["user"] != null || response["user"]?["id"].ToString() == Startup.ownerId)
|
if (response["user"] != null || response["user"]?["id"].ToString() == Startup.ownerId)
|
||||||
{
|
{
|
||||||
Author author = new()
|
try
|
||||||
{
|
{
|
||||||
discordId = ulong.Parse(response["user"]["id"].ToString()),
|
Author author = new()
|
||||||
discordNickName = response["user"]["global_name"].ToString()
|
{
|
||||||
};
|
discordId = ulong.Parse(response["user"]["id"].ToString()),
|
||||||
Blogs article = new()
|
discordNickName = response["user"]["global_name"].ToString()
|
||||||
|
};
|
||||||
|
Blogs article = new()
|
||||||
|
{
|
||||||
|
Annotation = body.annotation,
|
||||||
|
author = author,
|
||||||
|
dateTime = DateTime.Now,
|
||||||
|
ImageUrl = body.image,
|
||||||
|
Text = body.text,
|
||||||
|
Title = body.title
|
||||||
|
};
|
||||||
|
await Startup.dbContext.Blogs.AddAsync(article);
|
||||||
|
await Startup.dbContext.SaveChangesAsync();
|
||||||
|
return Ok(body);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Annotation = body.annotation,
|
Console.WriteLine("error: HomeController error");
|
||||||
author = author,
|
Console.WriteLine("debug: lines: 80-96");
|
||||||
dateTime = DateTime.Now,
|
Console.WriteLine($"debug: data from site: {body}");
|
||||||
ImageUrl = body.image,
|
Console.WriteLine($"debug: exception: {ex.Message}");
|
||||||
Text = body.text,
|
return StatusCode(500, body);
|
||||||
Title = body.title
|
}
|
||||||
};
|
|
||||||
await Startup.dbContext.Blogs.AddAsync(article);
|
|
||||||
await Startup.dbContext.SaveChangesAsync();
|
|
||||||
return Ok(body);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user