コード例 #1
0
        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);
        }
コード例 #2
0
 public void AddRecordToRepo(FisherGPS fg)
 {
     if (fg == null)
     {
         throw new ArgumentNullException("Error: The argument is Null");
     }
     FisherGPSCollection.Add(fg);
 }
コード例 #3
0
 public List <FisherGPS> GetAllFisherGPS(Fisher f = null)
 {
     if (f == null)
     {
         return(FisherGPSCollection.ToList());
     }
     else
     {
         return(FisherGPSCollection.Where(t => t.Fisher.FisherID == f.FisherID).ToList());
     }
 }
コード例 #4
0
        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());
            }
        }
コード例 #5
0
        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++;
            }
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 public FisherGPS GetFisherGPS(string ID)
 {
     return(FisherGPSCollection.FirstOrDefault(n => n.RowID == ID));
 }