private async void frmVerify_Load(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; ucVerifyFingerprint1.StaffVerified += UcVerifyFingerprint1_StaffVerified; using (var HC = new HttpClient()) { var response = await HC.GetAsync(Constants.baseUrl + $"Staff/Fingerprints"); if (response.IsSuccessStatusCode) { rtn = JsonConvert.DeserializeObject <ApiReturnObject <List <Fingerprint> > >(await response.Content.ReadAsStringAsync()); FPS = rtn.Object; } if (FPS.Count <= 0) { MessageBox.Show("An error occured while fetching fingerprints. Please try again later."); this.Close(); } else { ucVerifyFingerprint1.Enabled = true; ucVerifyFingerprint1.StartVerify(FPS); } } Cursor = Cursors.Default; }
public async Task <IActionResult> GetStaff([FromRoute] string StaffId, [FromRoute] string Password) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var Admin = await _context.Useracct.FirstOrDefaultAsync(m => m.Userid == StaffId && m.Pwd == Password); var rtn = new ApiReturnObject <Useracct>(); if (Admin == null) { rtn = new ApiReturnObject <Useracct>() { Message = "Login Failed, User not found.", Status = false, Object = Admin }; } else { var SA = await _context.Stafftab.FirstOrDefaultAsync(m => m.FpAuthorised == true && m.Staffid == Admin.Userid); if (SA == null) { rtn = new ApiReturnObject <Useracct>() { Message = "Login Failed, User is not Authorised to Access this module.", Status = false, Object = null }; } else { rtn = new ApiReturnObject <Useracct>() { Message = "Login Successful.", Status = true, Object = Admin }; } } return(Ok(rtn)); }
public async Task <IActionResult> FindStaffs([FromRoute] string StaffId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var staffs = await _context.Stafftab.Include(n => n.Fingerprints).Where(m => m.Staffid.Contains(StaffId) || m.Surname.Contains(StaffId) || m.Othernames.Contains(StaffId) || m.Firstname.Contains(StaffId) || m.Middlename.Contains(StaffId)).ToListAsync(); foreach (var item in staffs) { if (item.Fingerprints != null) { foreach (var i in item.Fingerprints) { i.Staff = null; } } } var rtn = new ApiReturnObject <List <Stafftab> >(); if (!staffs.Any()) { rtn = new ApiReturnObject <List <Stafftab> >() { Message = "No staff was found with such Name or Id.", Status = false, Object = staffs }; } else { rtn = new ApiReturnObject <List <Stafftab> >() { Message = "Found.", Status = true, Object = staffs }; } return(Ok(rtn)); }
public async Task <IActionResult> PostFingerprint([FromBody] Fingerprint FP) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var staff = await _context.Stafftab.FirstOrDefaultAsync(m => m.Id == FP.StafftabId); var rtn = new ApiReturnObject <Fingerprint>(); if (staff == null) { rtn = new ApiReturnObject <Fingerprint>() { Message = "Staff was not found.", Status = false, Object = null }; } else { _context.Fingerprints.Add(FP); _context.SaveChanges(); FP.Staff = null; rtn = new ApiReturnObject <Fingerprint>() { Message = "Fingerprint was saved successfully.", Status = true, Object = FP }; } return(Ok(rtn)); }
public async Task <IActionResult> GetFingerprints() { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var fps = await _context.Fingerprints.Include(n => n.Staff).ToListAsync(); foreach (var item in fps) { item.Staff.Fingerprints = null; } var rtn = new ApiReturnObject <List <Fingerprint> >() { Message = "List of fingerprints", Status = true, Object = fps }; return(Ok(rtn)); }