ปรับปรุงการทำ log

This commit is contained in:
LAPTOP-KB8JC2K2\acer
2021-05-30 12:41:44 +07:00
parent 0666c64024
commit 0dbfb54829
5 changed files with 127 additions and 10 deletions

View File

@@ -11,6 +11,8 @@ using TodoAPI2.Models;
using Microsoft.AspNetCore.Http;
using IdentityModel;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using TTSW.Utils;
namespace TTSW.EF
{
@@ -25,6 +27,7 @@ namespace TTSW.EF
{
#region Private Variables
private DataContext _context;
private IMyDatabase _db;
public DataContext Context
{
get
@@ -45,11 +48,12 @@ namespace TTSW.EF
}
#endregion
public BaseRepository2(DataContext context, IHttpContextAccessor contextAccessor
public BaseRepository2(DataContext context, IHttpContextAccessor contextAccessor, IMyDatabase mydatabase
)
{
_context = context;
_contextAccessor = contextAccessor;
_db = mydatabase;
}
#region Private Functions
@@ -269,7 +273,17 @@ namespace TTSW.EF
var userLogin = GetLoginProfile();
var existingItem = Get(id);
var old_existingItem = Get(id);
object old_existingItem;
try
{
var x = MyHelper.GetDataRow(id, model, _db);
old_existingItem = MyHelper.GetObject(x, model.GetType().Name.Replace("Entity", ""));
}
catch (Exception ex)
{
old_existingItem = null;
}
if (existingItem == null)
throw new NotificationException($"No item in database.");