public async Task <IActionResult> PutAttendanceItem([FromRoute] int id, [FromBody] AttendanceItem attendanceItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != attendanceItem.Id) { return(BadRequest()); } _context.Entry(attendanceItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttendanceItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Delete /// </summary> /// <param name="attendanceItemToDelete"></param> public void DeleteAttendanceItem(AttendanceItem attendanceItemToDelete) { using (CAAContext context = new CAAContext()) { context.AttendanceItems.Remove(attendanceItemToDelete); context.SaveChanges(); } }
/// <summary> /// Update /// </summary> /// <param name="attendanceItemToUpdate"></param> public void UpdateAttendanceItem(AttendanceItem attendanceItemToUpdate) { using (CAAContext context = new CAAContext()) { context.Update(attendanceItemToUpdate); context.SaveChanges(); } }
/// <summary> /// Add /// </summary> /// <param name="attendanceItemToAdd"></param> public void AddAttendanceItem(AttendanceItem attendanceItemToAdd) { using (CAAContext context = new CAAContext()) { context.AttendanceItems.Add(attendanceItemToAdd); context.SaveChanges(); } }
public async Task <IActionResult> PostAttendanceItem([FromBody] AttendanceItem attendanceItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.AttendanceItem.Add(attendanceItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAttendanceItem", new { id = attendanceItem.Id }, attendanceItem)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { GetAttendance aitem = new GetAttendance(); aitem.GetUserAttendance(mitem._EMPID); attendance.ItemsSource = StaticAttendanceList.staticAttendanceList; AttendanceItem item = new AttendanceItem(); fromDate.SelectedDate = item.NOW; toDate.SelectedDate = item.NOW; }
private void Window_Loaded(object sender, RoutedEventArgs e) { Comboboxitem.ComboItem.Clear(); AttendanceItem aitem = new AttendanceItem(); fromDate.SelectedDate = aitem.NOW; toDate.SelectedDate = aitem.NOW; UserPending upend = new UserPending(); upend.ComboItems(); CB.ItemsSource = Comboboxitem.ComboItem; }
private void SaveSurveyResponses() { foreach (var x in ListOfEID) { var surveyEntry = new AttendanceItem(); surveyEntry.EventItemID = x.EIDEventItemID; surveyEntry.MemberAttendanceID = tracker.MemberAttendanceID; if (tbkQuestionOne.Text == x.EIDItemPhrase) { if (ckbAnswerOne.Visibility == Visibility.Visible && ckbAnswerOne.IsChecked == true) { surveyEntry.Answer = "true"; } else if (ckbAnswerOne.Visibility == Visibility.Visible && ckbAnswerOne.IsChecked == false) { surveyEntry.Answer = "false"; } else { surveyEntry.Answer = txtAnswerOne.Text; } } else if (tbkQuestionTwo.Text == x.EIDItemPhrase) { if (ckbAnswerTwo.Visibility == Visibility.Visible && ckbAnswerTwo.IsChecked == true) { surveyEntry.Answer = "true"; } else if (ckbAnswerTwo.Visibility == Visibility.Visible && ckbAnswerTwo.IsChecked == false) { surveyEntry.Answer = "false"; } else { surveyEntry.Answer = txtAnswerTwo.Text; } } else if (tbkQuestionThree.Text == x.EIDItemPhrase) { if (ckbAnswerThree.Visibility == Visibility.Visible && ckbAnswerThree.IsChecked == true) { surveyEntry.Answer = "true"; } else if (ckbAnswerThree.Visibility == Visibility.Visible && ckbAnswerThree.IsChecked == false) { surveyEntry.Answer = "false"; } else { surveyEntry.Answer = txtAnswerThree.Text; } } else if (tbkQuestionFour.Text == x.EIDItemPhrase) { if (ckbAnswerFour.Visibility == Visibility.Visible && ckbAnswerFour.IsChecked == true) { surveyEntry.Answer = "true"; } else if (ckbAnswerFour.Visibility == Visibility.Visible && ckbAnswerFour.IsChecked == false) { surveyEntry.Answer = "false"; } else { surveyEntry.Answer = txtAnswerFour.Text; } } else if (tbkQuestionFive.Text == x.EIDItemPhrase) { if (ckbAnswerFive.Visibility == Visibility.Visible && ckbAnswerFive.IsChecked == true) { surveyEntry.Answer = "true"; } else if (ckbAnswerFive.Visibility == Visibility.Visible && ckbAnswerFive.IsChecked == false) { surveyEntry.Answer = "false"; } else { surveyEntry.Answer = txtAnswerFive.Text; } } try { attendanceItemRepository.AddAttendanceItem(surveyEntry); } catch { Jeeves.ShowMessage("Error", "There was a problem entering question " + x.EIDquestionCount.ToString()); } } }
public async Task <ClassInfoOutput> ProcessPhoto([FromBody] ClassInfoInput input) { ClassInfoOutput output = new ClassInfoOutput(); AspUserService aspUser = new AspUserService(_db, this); if (input == null) { Response.StatusCode = 400; output.Result = "INPUT_IS_NULL"; } else { if (aspUser.IsLecturer) { Class thisClass = aspUser.User.List_Classes.Where(e => e.Id.Equals(input.ClassId) && e.Deleted == false).FirstOrDefault(); if (thisClass == null) { Response.StatusCode = 400; output.Result = "CLASS_NOT_EXIST"; } else { string siteUrl = _db.SiteConfigs.Where(e => e.Key.Equals("SITEURL")).FirstOrDefault().Value; List <string> faceIds = new List <string>(); List <string> personIds = new List <string>(); List <GroupImage> images = thisClass.List_GroupImages.Where(e => e.Status == 1 && e.Deleted == false).ToList(); foreach (GroupImage item in images) { string personGroupId = _db.SiteConfigs.Where(e => e.Key.Equals("PERSONGROUP")).FirstOrDefault().Value; Uri uri = new Uri("https://bcp-facial.cognitiveservices.azure.com/face/v1.0/detect?recognitionModel=recognition_02"); HttpClientHandler handler = new HttpClientHandler(); StringContent queryString = null; HttpClient client = new HttpClient(handler); //string respond = null; ClassDetectImage detectImg = new ClassDetectImage() { Url = siteUrl + "/" + item.Url }; queryString = new StringContent(JsonConvert.SerializeObject(detectImg), Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "8d4c42ecbb784d909275492115ea56f0"); HttpResponseMessage response = await client.PostAsync(uri, queryString); string respond = await response.Content.ReadAsStringAsync(); dynamic jsonObj = JsonConvert.DeserializeObject(respond); foreach (var obj in jsonObj) { try { faceIds.Add((string)obj.faceId); } catch (RuntimeBinderException e) { e.ToString(); } } } bool completeCycle = false; int multiple = 0; while (!completeCycle) { List <string> tmpFaceIds = new List <string>(); for (int i = 0 + 10 * multiple; i < 10 + 10 * multiple; i++) { if (i > faceIds.Count() - 1) { completeCycle = true; } else { tmpFaceIds.Add(faceIds.ElementAt(i)); } } string personGroupId = _db.SiteConfigs.Where(e => e.Key.Equals("PERSONGROUP")).FirstOrDefault().Value; Uri uri = new Uri("https://bcp-facial.cognitiveservices.azure.com/face/v1.0/identify"); HttpClientHandler handler = new HttpClientHandler(); StringContent queryString = null; HttpClient client = new HttpClient(handler); //string respond = null; ClassIdentifyImage identifyImg = new ClassIdentifyImage() { ConfidenceThreshold = "0.5", MaxNumOfCandidatesReturned = "1", PersonGroupId = personGroupId, FaceIds = tmpFaceIds }; queryString = new StringContent(JsonConvert.SerializeObject(identifyImg), Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "8d4c42ecbb784d909275492115ea56f0"); HttpResponseMessage response = await client.PostAsync(uri, queryString); string respond = await response.Content.ReadAsStringAsync(); dynamic jsonObj = JsonConvert.DeserializeObject(respond); foreach (var obj in jsonObj) { try { foreach (var tmpObj in obj.candidates) { personIds.Add((string)tmpObj.personId); } } catch (RuntimeBinderException e) { e.ToString(); } } multiple++; } Attendance newAttendance = new Attendance() { Class = thisClass }; _db.Attendances.Add(newAttendance); foreach (ClassAllocation item in thisClass.List_ClassAllocation.Where(e => e.Deleted == false)) { if (personIds.Contains(item.Student.PersonId)) { AttendanceItem newAttendanceItem = new AttendanceItem() { Student = item.Student, Attendance = newAttendance }; _db.AttendanceItems.Add(newAttendanceItem); } } _db.SaveChanges(); } } else { Response.StatusCode = 400; output.Result = "NO_PRIVILEGE"; } } return(output); }