Пример #1
0
        public HomeDetails Add(HomeDetails item)
        {
            HomeData.Add(item);

            using (XmlWriter writer = XmlWriter.Create(DataSourceFile()))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Details");

                foreach (HomeDetails home in HomeData)
                {
                    writer.WriteStartElement("HomeDetails");

                    writer.WriteElementString("ID", home.ID.ToString());
                    writer.WriteElementString("Address", home.Address);
                    writer.WriteElementString("City", home.City);
                    writer.WriteElementString("State", home.State);
                    writer.WriteElementString("Zip", home.Zip.ToString());

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            return item;
        }
Пример #2
0
        //POST api/Home
        public HttpResponseMessage PostHomeDetails(HomeDetails item)
        {
            item = repository.Add(item);
            var response = Request.CreateResponse<HomeDetails>(HttpStatusCode.Created, item);

            string uri = Url.Link("DefaultApi", new { id = item.ID });
            response.Headers.Location = new Uri(uri);
            return response;
        }