public FisherGPS GetFisherGPS(Fisher fisher, GPS gps, ProjectSetting projectSetting, DateTime dateTimeDeparted, out EntityValidationMessage errorMessage) { errorMessage = new EntityValidationMessage(""); FisherGPS rv = null; foreach (FisherGPS fg in FisherGPSCollection.OrderBy(p => p.DateAssigned)) { if (fg.Fisher.FisherID == fisher.FisherID && fg.GPS.ID == gps.ID && fg.ProjectSetting.ProjectID == projectSetting.ProjectID) { if (fg.DateReturned != null) { } rv = fg; break; } } if (rv == null) { errorMessage = new EntityValidationMessage("No matching Fisher-GPS record was found. Check date and time departed"); } return(rv); }
public void AddRecordToRepo(FisherGPS fg) { if (fg == null) { throw new ArgumentNullException("Error: The argument is Null"); } FisherGPSCollection.Add(fg); }
public List <FisherGPS> GetAllFisherGPS(Fisher f = null) { if (f == null) { return(FisherGPSCollection.ToList()); } else { return(FisherGPSCollection.Where(t => t.Fisher.FisherID == f.FisherID).ToList()); } }
public List <FisherGPS> GetAllFisherGPS(GPS g, FisherGPS fg = null) { if (fg == null) { return(FisherGPSCollection.Where(t => t.GPS.ID == g.ID).ToList()); } else { return(FisherGPSCollection .Where(t => t.GPS.ID == g.ID) .Where(t => t.DateReturned != null) .Where(t => t.RowID != fg.RowID).ToList()); } }
public void DeleteRecordFromRepo(string id) { if (id == null) { throw new Exception("Record ID cannot be null"); } int index = 0; while (index < FisherGPSCollection.Count) { if (FisherGPSCollection[index].RowID == id) { FisherGPSCollection.RemoveAt(index); break; } index++; } }
public FisherGPS GetFisherGPS(FisherGPS fg, DateTime date) { try { return(FisherGPSCollection .Single(a => a.GPS.ID == fg.GPS.ID && a.DateAssigned <= date && a.RowID != fg.RowID && (a.DateReturned == null ? DateTime.Now : a.DateReturned) >= date)); } catch (System.InvalidOperationException) { return(null); } catch (Exception ex) { Logger.Log(ex); return(null); } }
public bool CanAssignGPS(Fisher f) { if (FisherGPSCollection.Count > 0) { if (GetAllFisherGPS(f).Count == 0) { return(true); } else { var maxRow = FisherGPSCollection .Where(d => d.Fisher.FisherID == f.FisherID) .MaxBy(d => d.DateAssigned).ToList()[0]; return(maxRow.DateReturned != null); } } else { return(true); } }
public FisherGPS GetFisherGPS(string ID) { return(FisherGPSCollection.FirstOrDefault(n => n.RowID == ID)); }