public void AddToVertexGraveyard(int buildingId, int vertexId)
        {
            //string errorMsg = "ERROR: Could not delete Vertex w. ID = " + vertexId + " from building w. ID = " + buildingId;
            //string succesMsg = "SUCCES: Deleted Vertex w. ID = " + vertexId + " from building w. ID = " + buildingId;

            //Check buildings exist
            Building graveyardBuilding = CurrentDataSource.Buildings.SingleOrDefault(b => b.ID == 18); //graveyard
            Building sourceBuilding    = CurrentDataSource.Buildings.SingleOrDefault(b => b.ID == buildingId);

            if (graveyardBuilding == null || sourceBuilding == null)
            {
                return; // errorMsg;
            }
            //Check vertex exists
            Vertex targetVertex = CurrentDataSource.Vertices.SingleOrDefault(v => v.ID == vertexId && v.Building_ID == buildingId);

            if (targetVertex == null)
            {
                return; // errorMsg;
            }
            //delete the vertex's edges
            IQueryable <Edge> targetEdges = CurrentDataSource.Edges.Where(e => e.vertexOrigin == vertexId || e.vertexDestination == vertexId);

            foreach (Edge e in targetEdges)
            {
                CurrentDataSource.Edges.DeleteObject(e);
            }

            //move the vertex from the original building to the VertexGraveyard building (the one with ID = 18)
            graveyardBuilding.Vertices.Add(targetVertex);
            sourceBuilding.Vertices.Remove(targetVertex);
            CurrentDataSource.SaveChanges();
        }
Пример #2
0
        public bool RatePolicy(int policyID)
        {
            IPolicyRater rater  = AIMS.Services.IoC.Container.Resolve <IPolicyRater>();
            var          policy = CurrentDataSource.Policies.Find(policyID);
            var          result = rater.Rate(policy, CurrentDataSource);

            CurrentDataSource.SaveChanges();
            return(result.Success);
        }
Пример #3
0
        public void RemoveFromGroup(string pid, string gid)
        {
            var _pid = Int32.Parse(pid);
            var _gid = Int32.Parse(gid);

            var _person = CurrentDataSource.GoupMail_Person.Where(x => x.ItemID == _pid).FirstOrDefault();
            var _group  = CurrentDataSource.GroupMail_Groups.Where(x => x.ItemID == _gid).FirstOrDefault();

            if (_person != null && _group != null)
            {
                _person.Lists.Remove(_group);
                CurrentDataSource.SaveChanges();
            }
        }
        public bool AddAttendee(string name, string email, string company, string registrationCode, int eventId)
        {
            if (!(from rc in this.CurrentDataSource.RegistrationCodes
                  where rc.RegistrationCode1 == registrationCode
                  select rc).Any())
            {
                return(false);
            }

            var attendee = new Attendee
            {
                Name             = name,
                Email            = email,
                Company          = company,
                RegistrationCode = registrationCode,
                EventId          = eventId
            };

            CurrentDataSource.Attendees.AddObject(attendee);
            return(!(CurrentDataSource.SaveChanges() < 1));
        }