add lastmodified and lastmodifiedid to table also add code for modified and create
This commit is contained in:
@@ -18,7 +18,7 @@ namespace CarParkValidationAPI.Repository
|
||||
public class ConcessionValidationRepository : IConcessionValidation
|
||||
{
|
||||
private DataContext _context;
|
||||
|
||||
private string _currentUser = "";
|
||||
private readonly AppSettings _appSettings;
|
||||
|
||||
public ConcessionValidationRepository(
|
||||
@@ -29,6 +29,10 @@ namespace CarParkValidationAPI.Repository
|
||||
_appSettings = appSettings.Value;
|
||||
}
|
||||
|
||||
public void SetCurrentUser(string username)
|
||||
{
|
||||
_currentUser = username;
|
||||
}
|
||||
private ConcessionValidationDto FillConcessionValidationDto(ConcessionValidation model)
|
||||
{
|
||||
ConcessionValidationDto dto = new ConcessionValidationDto();
|
||||
@@ -167,7 +171,7 @@ namespace CarParkValidationAPI.Repository
|
||||
{
|
||||
var anyRecord = await _context.SelectCheckConcessionValidationAsync(currentDate.ToLocalTime().Date, concessionCard, staffLinkNo);
|
||||
|
||||
if (anyRecord.Count > 0)
|
||||
if (anyRecord.Count > 1)
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
@@ -267,6 +271,7 @@ namespace CarParkValidationAPI.Repository
|
||||
int result = default(int);
|
||||
int statuscode = 0;
|
||||
string error = "";
|
||||
//_currentUser = item.StafflinkNo;
|
||||
try
|
||||
{
|
||||
ConcessionValidation model;
|
||||
@@ -274,12 +279,18 @@ namespace CarParkValidationAPI.Repository
|
||||
{
|
||||
model = await _context.ConcessionValidations.FindAsync(item.Id);
|
||||
model = FillConcessionValidation(item, model);
|
||||
model.LastModified = DateTime.Now;
|
||||
model.LastModifiedId = _currentUser;
|
||||
result = await _context.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
model = new ConcessionValidation();
|
||||
model = FillConcessionValidation(item, model);
|
||||
model.LastModified = DateTime.Now;
|
||||
model.LastModifiedId = _currentUser;
|
||||
model.CreatedDate = DateTime.Now;
|
||||
model.CreatedId = _currentUser;
|
||||
_context.ConcessionValidations.Add(model);
|
||||
result = await _context.SaveChangesAsync();
|
||||
}
|
||||
@@ -312,8 +323,10 @@ namespace CarParkValidationAPI.Repository
|
||||
if (id > 0)
|
||||
{
|
||||
ConcessionValidation model = await _context.ConcessionValidations.FindAsync(id);
|
||||
// model.Active = false;
|
||||
_context.ConcessionValidations.Remove(model);
|
||||
model.Active = false;
|
||||
model.LastModified = DateTime.Now;
|
||||
model.LastModifiedId = _currentUser;
|
||||
//_context.ConcessionValidations.Remove(model);
|
||||
await _context.SaveChangesAsync();
|
||||
statuscode = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user