Exemple #1
0
 public JsonNetResult Edit(EventRelationshipViewModel vm)
 {
     if (ModelState.IsValid)
     {
         EventRelationship relationship = this.eventTasks.GetEventRelationship(vm.Id);
         if (relationship != null)
         {
             Mapper.Map <EventRelationshipViewModel, EventRelationship>(vm, relationship);
             relationship.SubjectEvent          = this.eventTasks.GetEvent(vm.SubjectEventId.Value);
             relationship.ObjectEvent           = this.eventTasks.GetEvent(vm.ObjectEventId.Value);
             relationship.EventRelationshipType = this.eventTasks.GetEventRelationshipType(vm.EventRelationshipTypeId);
             relationship = this.eventTasks.SaveEventRelationship(relationship);
             return(JsonNet(string.Empty));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Event relationship not found."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
Exemple #2
0
        public ActionResult Edit(int id)
        {
            EventRelationship relationship = this.eventTasks.GetEventRelationship(id);

            if (relationship != null)
            {
                EventRelationshipViewModel vm = new EventRelationshipViewModel(relationship);
                vm.PopulateDropDowns(this.eventTasks.GetEventRelationshipTypes());
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
Exemple #3
0
        public JsonNetResult Delete(int id)
        {
            EventRelationship relationship = this.eventTasks.GetEventRelationship(id);

            if (relationship != null)
            {
                this.eventTasks.DeleteEventRelationship(relationship);
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(JsonNet("Event relationship successfully deleted."));
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(JsonNet("Event relationship not found."));
            }
        }
Exemple #4
0
 public JsonNetResult Add(EventRelationshipViewModel vm)
 {
     if (ModelState.IsValid)
     {
         EventRelationship relationship = new EventRelationship();
         Mapper.Map <EventRelationshipViewModel, EventRelationship>(vm, relationship);
         relationship.SubjectEvent          = this.eventTasks.GetEvent(vm.SubjectEventId.Value);
         relationship.ObjectEvent           = this.eventTasks.GetEvent(vm.ObjectEventId.Value);
         relationship.EventRelationshipType = this.eventTasks.GetEventRelationshipType(vm.EventRelationshipTypeId);
         relationship = this.eventTasks.SaveEventRelationship(relationship);
         return(JsonNet(string.Empty));
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
Exemple #5
0
        public IList <EventRelationship> GetEventRelationships(Person p)
        {
            EventRelationship er = null;

            var subquery = QueryOver.Of <PersonResponsibility>()
                           .Where(x => x.Person == p)
                           .And(x => !x.Archive)
                           .Select(x => x.Event);

            return(Session.QueryOver <EventRelationship>(() => er)
                   .Where(Restrictions.Disjunction()
                          .Add(Subqueries.WhereProperty(() => er.SubjectEvent).In(subquery))
                          .Add(Subqueries.WhereProperty(() => er.ObjectEvent).In(subquery))
                          )
                   .And(x => !x.Archive)
                   .List());
        }
 public EventRelationshipViewModel(EventRelationship er)
 {
     if (er != null)
     {
         this.Id = er.Id;
         if (er.SubjectEvent != null)
         {
             this.SubjectEventId = er.SubjectEvent.Id;
         }
         if (er.ObjectEvent != null)
         {
             this.ObjectEventId = er.ObjectEvent.Id;
         }
         if (er.EventRelationshipType != null)
         {
             this.EventRelationshipTypeId = er.EventRelationshipType.Id;
         }
         this.Archive = er.Archive;
         this.Notes   = er.Notes;
     }
 }
Exemple #7
0
        /// <summary>
        /// Evvents and links between them
        /// </summary>
        /// <returns>A list of past events</returns>
        public static List <MemoryItem> CreateEventsAndPersons(IItemLinkFactory itemLinkFactory)
        {
            var eventsAndPersons = new List <MemoryItem>();

            PastEvent event1 = new PastEvent("the Age of Migration", Guid.NewGuid(), MigrationDesc)
            {
                Type    = PastEventType.Social,
                Started = new CustomDateTime(-2230),
                Ended   = new CustomDateTime(-2230)
            };

            PastEvent event2 = new PastEvent("The Conjunction of the Spheres", Guid.NewGuid(), ConjunctionDesc)
            {
                Type    = PastEventType.Magical,
                Started = new CustomDateTime(-230),
                Ended   = new CustomDateTime(-230)
            };

            PastEvent event3 = new PastEvent("The Resurrection", Guid.NewGuid())
            {
                Type    = PastEventType.Magical,
                Started = new CustomDateTime(1),
                Ended   = new CustomDateTime(1),
            };
            PastEvent event4 = new PastEvent("The Nilfgaardian invasion", Guid.NewGuid())
            {
                Type        = PastEventType.Battle,
                Description = "Invasion by Nilfgaard"
            };

            EventRelationship link1 = new EventRelationship(event2, EventRelationshipType.Preceded, Guid.NewGuid());

            event3.AddEventLink(link1);

            EventRelationship link2 = new EventRelationship(event4, EventRelationshipType.Followed, Guid.NewGuid());

            event3.AddEventLink(link2);

            Person Anya    = new Person("Anya", Gender.Female, Sex.Female, Orientation.Straight, Guid.NewGuid(), new CustomDateTime(1166, 6, 7));
            Person Hanselt = new Person("Hanselt", Gender.Male, Sex.Male, Orientation.Bisexual, Guid.NewGuid(), new CustomDateTime(1159, 3, 19));
            Person Rilbert = new Person("Rilbert", Guid.NewGuid());

            PastEvent conflict1 = new PastEvent("Hanselt and Rilbert had a fight in a tavern", Guid.NewGuid())
            {
                Type        = PastEventType.Conflict,
                Description = "There was enmity between Hanselt and Rilbert fought in a tavern",
                Started     = new CustomDateTime(1179, 5, 11),
                Ended       = new CustomDateTime(1179, 5, 11)
            };

            PastEvent conflict2 = new PastEvent("Hanselt and Rilbert had a fight in a tavern", Guid.NewGuid())
            {
                Type        = PastEventType.Conflict,
                Description = "Hanselt grew jealous of Rilbert after Anya fell in love with Rilbert",
                Started     = new CustomDateTime(1183, 2, 30)
            };

            itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(Hanselt, conflict1, PersonalInvolvementType.ParticipatedIn);
            itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(Rilbert, conflict1, PersonalInvolvementType.ParticipatedIn);

            itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(Hanselt, conflict2, PersonalInvolvementType.ParticipatedIn);
            itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(Rilbert, conflict2, PersonalInvolvementType.ParticipatedIn);

            eventsAndPersons.Add(event1);
            eventsAndPersons.Add(event2);
            eventsAndPersons.Add(event3);
            eventsAndPersons.Add(event4);
            eventsAndPersons.Add(Anya);
            eventsAndPersons.Add(Hanselt);
            eventsAndPersons.Add(Rilbert);
            eventsAndPersons.Add(conflict1);
            eventsAndPersons.Add(conflict2);

            return(eventsAndPersons);
        }
Exemple #8
0
 public void DeleteEventRelationship(EventRelationship relationship)
 {
     relationship.SubjectEvent.RemoveEventRelationshipAsSubject(relationship);
     relationship.ObjectEvent.RemoveEventRelationshipAsObject(relationship);
     this.eventRelationshipRepo.Delete(relationship);
 }
Exemple #9
0
 public EventRelationship SaveEventRelationship(EventRelationship relationship)
 {
     relationship.SubjectEvent.AddEventRelationshipAsSubject(relationship);
     relationship.ObjectEvent.AddEventRelationshipAsObject(relationship);
     return(this.eventRelationshipRepo.SaveOrUpdate(relationship));
 }