Exemple #1
0
        public ActionResult CreatePerson(NewPerson vm)
        {
            var db    = new DatabaseContext();
            var place = db.Places.FirstOrDefault(place => place.Id == vm.PlaceId);

            if (place == null)
            {
                return(NotFound());
            }
            else
            {
                var newPerson = new Person
                {
                    CharacterName = vm.CharacterName,
                    ActorName     = vm.ActorName,
                    MainCharacter = vm.MainCharacter,
                    Human         = vm.Human,
                    PlaceId       = vm.PlaceId
                };
                db.Persons.Add(newPerson);
                db.SaveChanges();
                var rv = new CreatedPerson
                {
                    Id            = newPerson.Id,
                    CharacterName = newPerson.CharacterName,
                    ActorName     = newPerson.ActorName,
                    MainCharacter = newPerson.MainCharacter,
                    PlaceId       = newPerson.PlaceId,
                    Human         = newPerson.Human
                };
                return(Ok(rv));
            }
        }
Exemple #2
0
        private void AddFilterSection(XmlWriter writer)
        {
            if (AreFiltersPresent())
            {
                // <filter>
                writer.WriteStartElement("filter");

                if (_typeIds.Count > 0)
                {
                    // <type-id>
                    foreach (Guid typeId in _typeIds)
                    {
                        writer.WriteElementString(
                            "type-id", typeId.ToString());
                    }
                }

                if ((States & ThingStates.Active) != 0)
                {
                    // <thing-state>
                    writer.WriteElementString(
                        "thing-state",
                        ThingState.Active.ToString());
                }

                if ((States & ThingStates.Deleted) != 0)
                {
                    // <thing-state>
                    writer.WriteElementString(
                        "thing-state",
                        ThingState.Deleted.ToString());
                }

                if (EffectiveDateMin != null)
                {
                    // <eff-date-min>
                    writer.WriteStartElement("eff-date-min");
                    writer.WriteValue(SDKHelper.XmlFromLocalDateTime(EffectiveDateMin.Value));
                    writer.WriteEndElement();
                }

                if (EffectiveDateMax != null)
                {
                    // <eff-date-max>
                    writer.WriteStartElement("eff-date-max");
                    writer.WriteValue(SDKHelper.XmlFromLocalDateTime(EffectiveDateMax.Value));
                    writer.WriteEndElement();
                }

                if (_createdApplication != null)
                {
                    // <created-application>
                    writer.WriteStartElement("created-app-id");
                    writer.WriteValue(CreatedApplication.ToString());
                    writer.WriteEndElement();
                }

                if (_createdPerson != null)
                {
                    // <created-person>
                    writer.WriteStartElement("created-person-id");
                    writer.WriteValue(CreatedPerson.ToString());
                    writer.WriteEndElement();
                }

                if (_updatedApplication != null)
                {
                    // <updated-application>
                    writer.WriteStartElement("updated-app-id");
                    writer.WriteValue(UpdatedApplication.ToString());
                    writer.WriteEndElement();
                }

                if (_updatedPerson != null)
                {
                    // <updated-person>
                    writer.WriteStartElement("updated-person-id");
                    writer.WriteValue(UpdatedPerson.ToString());
                    writer.WriteEndElement();
                }

                if (_createdDateMin != null)
                {
                    // <created-date-min>
                    writer.WriteStartElement("created-date-min");
                    writer.WriteValue(CreatedDateMin);
                    writer.WriteEndElement();
                }

                if (_createdDateMax != null)
                {
                    // <created-date-max>
                    writer.WriteStartElement("created-date-max");
                    writer.WriteValue(CreatedDateMax);
                    writer.WriteEndElement();
                }

                if (_updatedDateMin != null)
                {
                    // <updated-date-min>
                    writer.WriteStartElement("updated-date-min");
                    writer.WriteValue(UpdatedDateMin);
                    writer.WriteEndElement();
                }

                if (_updatedDateMax != null)
                {
                    // <updated-date-max>
                    writer.WriteStartElement("updated-date-max");
                    writer.WriteValue(UpdatedDateMax);
                    writer.WriteEndElement();
                }

                if (!string.IsNullOrEmpty(XPath))
                {
                    // <xpath>
                    writer.WriteStartElement("xpath");
                    writer.WriteValue(XPath);
                    writer.WriteEndElement();
                }

                if (_updatedEndDateMax != null)
                {
                    // <updated-end-date-max>
                    writer.WriteStartElement("updated-end-date-max");
                    writer.WriteValue(UpdatedEndDateMax);
                    writer.WriteEndElement();
                }

                if (_updatedEndDateMin != null)
                {
                    // <updated-end-date-min>
                    writer.WriteStartElement("updated-end-date-min");
                    writer.WriteValue(UpdatedEndDateMin);
                    writer.WriteEndElement();
                }

                // </filter>
                writer.WriteEndElement();
            }
        }