Beispiel #1
0
        public bool Delete(CompoundIdentity sampleEventId, bool fileOnly, KnownDetType type)
        {
            if (type == KnownDetType.WaterQuality)  //For each known type, we need to add a block here
            {
                WqDetProcessor p = new WqDetProcessor(this.ctx);

                SampleEventMap map = DetRegistry.Instance.Get(sampleEventId);
                if (map.Contains(type))
                {
                    SampleEventMapItem it = map.Get(type);
                    if (it != null)
                    {
                        if (p.Delete(map, fileOnly)) //note the permission is checked in there
                        {
                            map.Remove(it.DetId);
                            if (!map.IsEmpty)
                            {
                                return(DetRegistry.Instance.Update(map));
                            }
                            else
                            {
                                return(DetRegistry.Instance.Delete(map.SampleEventId));
                            }
                        }
                    }
                }
            }
            else if (type == KnownDetType.Fish)
            {
                FishDetProcessor f = new FishDetProcessor(this.ctx);

                SampleEventMap map = DetRegistry.Instance.Get(sampleEventId);
                if (map.Contains(type))
                {
                    SampleEventMapItem it = map.Get(type);
                    if (it != null)
                    {
                        if (f.Delete(map, fileOnly)) //note the permission is checked in there
                        {
                            map.Remove(it.DetId);
                            if (!map.IsEmpty)
                            {
                                return(DetRegistry.Instance.Update(map));
                            }
                            else
                            {
                                return(DetRegistry.Instance.Delete(map.SampleEventId));
                            }
                        }
                    }
                }
            }
            else if (type == KnownDetType.Veg)
            {
                VegDetProcessor v   = new VegDetProcessor(this.ctx);
                SampleEventMap  map = DetRegistry.Instance.Get(sampleEventId);
                if (map.Contains(type))
                {
                    SampleEventMapItem it = map.Get(type);
                    if (it != null)
                    {
                        if (v.Delete(map, fileOnly)) //note the permission is checked in there
                        {
                            map.Remove(it.DetId);
                            if (!map.IsEmpty)
                            {
                                return(DetRegistry.Instance.Update(map));
                            }
                            else
                            {
                                return(DetRegistry.Instance.Delete(map.SampleEventId));
                            }
                        }
                    }
                }
            }

            return(false);
        }