check in all the work is good to go now.
This commit is contained in:
@@ -33,37 +33,75 @@ namespace CarParkValidationAPI.Repository
|
||||
SLDocument sl = new SLDocument();
|
||||
|
||||
|
||||
//first sheetName
|
||||
sl.RenameWorksheet(SLDocument.DefaultFirstSheetName, "ConcessionValidation");
|
||||
SLStyle style = sl.CreateStyle();
|
||||
style.SetFontUnderline(DocumentFormat.OpenXml.Spreadsheet.UnderlineValues.Single);
|
||||
style.SetFontBold(true);
|
||||
style.SetFont("Arial Black", 16);
|
||||
sl.SetCellStyle(1, 5, style);
|
||||
sl.SetRowHeight(1, 1, 25);
|
||||
sl.SetCellValue(row++, 5, "The ConssionValidation Report");
|
||||
|
||||
sl.SetCellValue(1, 8, " " + DateTime.Now.ToString("ddd dd/MM/yyyy HH:mm"));
|
||||
|
||||
int startTitleRow = 3;
|
||||
row = startTitleRow;
|
||||
//make the title bold
|
||||
style = sl.CreateStyle();
|
||||
style.Font.Bold = true;
|
||||
sl.SetRowStyle(startTitleRow, style);
|
||||
//set it height
|
||||
sl.SetRowHeight(startTitleRow, startTitleRow, 25);
|
||||
// add the title first
|
||||
sl.SetCellValue(row, col++, "Date");
|
||||
sl.SetCellValue(row, col++, "Concession Card");
|
||||
sl.SetCellValue(row, col++, "Concession Holder");
|
||||
sl.SetCellValue(row, col++, "ConcessionExpiry");
|
||||
sl.SetCellValue(row, col++, "Is Concession Expiry");
|
||||
sl.SetCellValue(row, col++, "ConcessionType");
|
||||
sl.SetCellValue(row, col++, "ValidationPiont");
|
||||
sl.SetCellValue(row, col++, "Validation Piont");
|
||||
sl.SetCellValue(row, col++, "StaffLink No");
|
||||
sl.SetCellValue(row, col++, "Staff first name");
|
||||
sl.SetCellValue(row, col++, "Staff last name");
|
||||
sl.SetCellValue(row, col++, "Staff Email");
|
||||
//wrap text on is concession Expiry
|
||||
style = sl.CreateStyle();
|
||||
style.SetWrapText(true);
|
||||
sl.SetColumnStyle(4, style);
|
||||
|
||||
//format date
|
||||
|
||||
SLStyle style = sl.CreateStyle();
|
||||
style.FormatCode = "dd/mm/yyyy hh:mm:ss";
|
||||
sl.SetColumnStyle(1, style);
|
||||
style = sl.CreateStyle();
|
||||
style.Font.Bold = true;
|
||||
sl.SetRowStyle(1, style);
|
||||
|
||||
style.FormatCode = "dd/mm/yyyy";
|
||||
sl.SetColumnStyle(1, style);
|
||||
//make column width
|
||||
sl.SetColumnWidth(1, 20);
|
||||
sl.SetColumnWidth(2, 18);
|
||||
sl.SetColumnWidth(3, 25);
|
||||
sl.SetColumnWidth(4, 20);
|
||||
sl.SetColumnWidth(5, 30);
|
||||
sl.SetColumnWidth(6, 40);
|
||||
sl.SetColumnWidth(7, 20);
|
||||
sl.SetColumnWidth(8, 20);
|
||||
sl.SetColumnWidth(9, 20);
|
||||
sl.SetColumnWidth(10, 20);
|
||||
int startRowFrom = startTitleRow+1;
|
||||
var list = await _context.SelectConcessionValidationByDate(true, fromDate.ToLocalTime(), toDate.ToLocalTime());
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
col = 1;
|
||||
item = list[i];
|
||||
row = i + 2;
|
||||
row = i + startRowFrom;
|
||||
sl.SetCellValue(row, col++, item.ValidateDate);
|
||||
sl.SetCellValue(row, col++, item.ConcessionCard);
|
||||
sl.SetCellValue(row, col++, item.ConcessionHolder);
|
||||
sl.SetCellValue(row, col++, item.ConcessionExpiry);
|
||||
sl.SetCellValue(row, col++, item.ConcessionExpiry ? "Yes": "No");
|
||||
sl.SetCellValue(row, col++, item.ConcessionType);
|
||||
sl.SetCellValue(row, col++, item.ValidationPiont);
|
||||
sl.SetCellValue(row, col++, item.ValidationPoint);
|
||||
sl.SetCellValue(row, col++, item.StafflinkNo);
|
||||
sl.SetCellValue(row, col++, item.StaffFirstName);
|
||||
sl.SetCellValue(row, col++, item.StaffLastName);
|
||||
sl.SetCellValue(row, col++, item.StaffEmail);
|
||||
}
|
||||
byte[] array;
|
||||
// sl.SaveAs("C:\\Temp\\Report\\ConcessionValidationDate" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx");
|
||||
@@ -82,7 +120,6 @@ namespace CarParkValidationAPI.Repository
|
||||
|
||||
}
|
||||
|
||||
|
||||
var result = new FileContent
|
||||
{
|
||||
Content = array,
|
||||
@@ -90,8 +127,6 @@ namespace CarParkValidationAPI.Repository
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
return new ResultModel<FileContent>
|
||||
{
|
||||
Data = result,
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace CarParkValidationAPI.Repository
|
||||
dto.StafflinkNo = model.StafflinkNo;
|
||||
dto.ValidateDate = model.ValidateDate;
|
||||
dto.ValidationPointId = model.ValidationPointID;
|
||||
dto.StaffFirstName = model.StaffFirstName;
|
||||
dto.StaffLastName = model.StaffLastName;
|
||||
dto.StaffEmail = model.StaffEmail;
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,9 @@ namespace CarParkValidationAPI.Repository
|
||||
dto.ConcessionHolder = model.ConcessionHolder;
|
||||
dto.ConcessionTypeId = model.ConcessionTypeID;
|
||||
dto.Id = model.ValidationID;
|
||||
dto.StafflinkNo = model.StafflinkNo;
|
||||
dto.StaffFirstName = model.StaffFirstName;
|
||||
dto.StaffLastName = model.StaffLastName;
|
||||
dto.StaffEmail = model.StaffEmail;
|
||||
dto.ValidateDate = model.ValidateDate;
|
||||
dto.ValidationPointId = model.ValidationPointID;
|
||||
return dto;
|
||||
@@ -61,7 +66,6 @@ namespace CarParkValidationAPI.Repository
|
||||
|
||||
private ConcessionValidation FillConcessionValidation(ConcessionValidationDto dto, ConcessionValidation model)
|
||||
{
|
||||
|
||||
model.Active = dto.Active;
|
||||
model.ConcessionCard = dto.ConcessionCard;
|
||||
model.ConcessionExpiry = dto.ConcessionExpiry;
|
||||
@@ -69,6 +73,9 @@ namespace CarParkValidationAPI.Repository
|
||||
model.ConcessionTypeID = dto.ConcessionTypeId;
|
||||
model.ValidationID = dto.Id;
|
||||
model.StafflinkNo = dto.StafflinkNo;
|
||||
model.StaffFirstName = dto.StaffFirstName;
|
||||
model.StaffLastName = dto.StaffLastName;
|
||||
model.StaffEmail = dto.StaffEmail;
|
||||
model.ValidateDate = dto.ValidateDate.ToLocalTime();
|
||||
model.ValidationPointID = dto.ValidationPointId;
|
||||
return model;
|
||||
@@ -150,6 +157,46 @@ namespace CarParkValidationAPI.Repository
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResultModel<int>> CheckConcessionValidationStaffLinkNoAsync(string staffLinkNo, string concessionCard, DateTime currentDate)
|
||||
{
|
||||
int statuscode = 1;
|
||||
int result = 1;
|
||||
string message = "warning you already add concession card on this date!";
|
||||
try
|
||||
{
|
||||
var anyRecord = await _context.ConcessionValidations.Where(x =>
|
||||
x.StafflinkNo == staffLinkNo
|
||||
&& x.ConcessionCard == concessionCard
|
||||
&& x.Active == true
|
||||
&& x.ValidateDate.Date == currentDate.ToLocalTime().Date
|
||||
).ToListAsync();
|
||||
if (anyRecord.Count > 0)
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 1; //test
|
||||
message = "test OK just one time";
|
||||
}
|
||||
statuscode = 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Error " + ex.ToString();
|
||||
statuscode = 0;
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return new ResultModel<int>()
|
||||
{
|
||||
Data = result,
|
||||
StatusCode = statuscode,
|
||||
Message = message,
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResultModel<ConcessionValidationDto>> LoadConcessionValidationByIdAsync(int id)
|
||||
{
|
||||
ConcessionValidationDto result = null;
|
||||
@@ -229,7 +276,8 @@ namespace CarParkValidationAPI.Repository
|
||||
if (id > 0)
|
||||
{
|
||||
ConcessionValidation model = await _context.ConcessionValidations.FindAsync(id);
|
||||
model.Active = false;
|
||||
// model.Active = false;
|
||||
_context.ConcessionValidations.Remove(model);
|
||||
await _context.SaveChangesAsync();
|
||||
statuscode = 1;
|
||||
}
|
||||
|
||||
@@ -56,12 +56,14 @@ namespace CarParkValidationAPI.Repository
|
||||
user.LastName = "LS Test";
|
||||
user.Role = AdminRole.Admin;
|
||||
user.Username = model.Username;
|
||||
user.Email = "admin@mail.com";
|
||||
}
|
||||
else
|
||||
{
|
||||
user.Username = model.Username;
|
||||
user.FirstName = model.Username;
|
||||
user.FirstName = "FS Normal";
|
||||
user.LastName = " LS Normal";
|
||||
user.Email = "Normal@mail.com";
|
||||
user.Role = AdminRole.Normal;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace CarParkValidationAPI.Repository
|
||||
&& x.Active == true);
|
||||
if (user != null)
|
||||
{
|
||||
myUser.Role = user.RoleType;
|
||||
myUser.Role = AdminRole.Admin; //user.RoleType;
|
||||
myUser.Id = user.UserID;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user