/// <summary> /// Action for Veteran. /// </summary> /// <param name="timeId"></param> public async void AcceptTimeSlot(int timeId) { LawyerAvailability timeSlot = _context.LawyerAvailability.Find(timeId); // Add timeslot to match obj VeteranLawyerMatch match = await GetMatchAsync(); match.TimeSelected = timeSlot.TimeAvailable; match.IsDateTimeApproved = true; // Remove timeslot from availability obj _context.LawyerAvailability.Remove(timeSlot); _context.SaveChanges(); }
/// <summary> /// Action for Veteran. /// </summary> /// <returns></returns> public async Task <VeteranLawyerMatch> GetMatchAsync() { string userid = _userManager.GetUserId(_httpContext.User); VeteranLawyerMatch match = await _context.VeteranLawyerMatches.FirstOrDefaultAsync(x => x.VeteranApplicationUserId == userid); if (match != null) { match.Lawyer = _context.Lawyers.Find(match.LawyerApplicationUserId); match.Lawyer.ApplicationUser = _context.Users.Find(match.Lawyer.ApplicationUserId); } return(match); }
public void FindVeteran() { if (_context.VeteranQueue.Any()) { string userid = _userManager.GetUserId(_httpContext.User); VeteranQueue vq = _context.VeteranQueue.First(); VeteranLawyerMatch newMatch = new VeteranLawyerMatch(); newMatch.IsDateTimeApproved = false; newMatch.IsLocationApproved = false; newMatch.LawyerApplicationUserId = userid; newMatch.VeteranApplicationUserId = vq.VeteranApplicationUserId; _context.VeteranLawyerMatches.Add(newMatch); _context.SaveChanges(); _context.VeteranQueue.Remove(vq); _context.SaveChanges(); } }