public int AddFlightReview(FlightReview flightReview) { _repository.Add<FlightReview>(flightReview); _repository.UnitOfWork.SaveChanges(); return flightReview.Id; }
public ActionResult UpdateFlightReview(FlightReviewViewModel viewModel) { Member pilot = _dataService.GetMember(viewModel.PilotId); FlightReview review = new FlightReview() { Date = (DateTime)viewModel.ReviewDate, InstructorName = viewModel.InstructorName, InstructorNotes = viewModel.Notes, PilotId = viewModel.PilotId, ReviewType = viewModel.ReviewType, RetractTime = viewModel.RetractTime, TotalTime = viewModel.TotalTime }; _dataService.AddFlightReview(review); return PilotReview(pilot.Id); }
public void ImportReviews() { IEnumerator<NtfcDataSet.BFRRow> rows = _dataSet.BFR.GetEnumerator(); List<Member> members = _dbContext.Members.Include(m => m.Login).ToList(); foreach (var member in members) { NtfcDataSet.BFRRow srcLastReview = _dataSet.BFR .Where(r => r.Member_ID == member.Login.MemberPIN && !r.IsInstructor_MIDNull()) .OrderByDescending(r => r.Review_date) .FirstOrDefault(); if (member.Login.MemberPIN == "537") System.Diagnostics.Debug.WriteLine("Flight review 537"); if (srcLastReview != null && !srcLastReview.IsReview_dateNull()) { Member instructor = _dbContext.Members.FirstOrDefault(m => m.Login.MemberPIN == srcLastReview.Instructor_MID); FlightReview flightReview = new FlightReview() { Date = srcLastReview.Review_date, Pilot = member, InstructorName = instructor.FullName }; if (!srcLastReview.Istotal_timeNull()) flightReview.TotalTime = Single.Parse(srcLastReview.total_time); if (!srcLastReview.Isretract_timeNull()) flightReview.RetractTime = Single.Parse(srcLastReview.retract_time); _dbContext.FlightReviews.Add(flightReview); } } _dbContext.SaveChanges(); }