public string RecieveToken() { //Get today's date as a code model ChallengeCode challengeCode = new ChallengeCode(); //Pass model to get today's token and return today's token. return(this._challengeCodeData.ReadT(challengeCode)._code); }
public void GenerateToken() { //Generate the token ChallengeCode challengeCode = new ChallengeCode(); //Pass the token to be added to the database this._challengeCodeData.CreateT(challengeCode); }
public void CheckIn(ChallengeCode code, User user) { string correctCode = this._challengeCodeData.ReadT(code)._code; if (code._code == correctCode) { if (this._attendanceData.ReadT(user)._userId != -1) { throw new AlreadyCheckedInException("You have already been checked in."); } this._attendanceData.CreateT(user); } else { throw new IncorrectCodeException("The code you used was not correct for todays code."); } }
public ActionResult getAttendance(ChallengeCode code) { try { if (!ModelState.IsValid) { return(View("Attendance")); } ViewData["attendance"] = this._attendanceService.GetAttendance(code._date); return(View("Attendance")); }catch (Exception e) { ViewBag.Error = e.Message; Console.WriteLine(e.StackTrace); return(View("Attendance")); } }
public ActionResult CheckIn(ChallengeCode code) { try { if (!ModelState.IsValid) { return(View()); } User principal = (User)HttpContext.Session["principal"]; this._attendanceService.CheckIn(code, principal); return(View("~/Views/Home/Index.cshtml")); }catch (Exception e) { ViewBag.Error = e.Message; Console.WriteLine(e.StackTrace); return(View()); } }
public ActionResult downloadAttendance(ChallengeCode code) { try { if (!ModelState.IsValid) { return(View("Attendance")); } List <User> attendance = this._attendanceService.DownloadAttendance(code._date); XLWorkbook workbook = new XLWorkbook(); IXLWorksheet worksheet = workbook.Worksheets.Add("pinetech"); worksheet.Cell(1, 1).SetValue("Full Name"); worksheet.Cell(1, 2).SetValue("User Name"); worksheet.Cell(1, 3).SetValue("Email"); int i = 1; foreach (var u in attendance) { i++; worksheet.Cell(i, 1).SetValue(u._fullName); worksheet.Cell(i, 2).SetValue(u._credentials._userName); worksheet.Cell(i, 3).SetValue(u._email); } MemoryStream ms = new MemoryStream(); workbook.SaveAs(ms); ms.Position = 0; return(new FileStreamResult(ms, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "Attendance.xlsx" }); } catch (Exception e) { ViewBag.Error = e.Message; Console.WriteLine(e.StackTrace); return(View("Attendance")); } }