ปรับปรุงการทำ log
This commit is contained in:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user