public IHttpActionResult GetCreateOrder(string _IdC) { int _id = int.Parse(_IdC); Customer custumer = db.Customer.Find(_id); GenericImplement <OrderSet> _GenericMethod = new GenericImplement <OrderSet>(); if (custumer == null) { return(NotFound()); } OrderSet _Order = new OrderSet(); _GenericMethod.Insert(_Order); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_Order.GetType()); var _StringWriter = new StringWriter(); XmlWriter _Writer = XmlWriter.Create(_StringWriter); x.Serialize(_Writer, _Order); string _Xml = _StringWriter.ToString(); return(Ok(_Xml)); }
// GET: api/OrderXml public IHttpActionResult GetOrder() { OrderSet _Order = new OrderSet(); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_Order.GetType()); var _StringWriter = new StringWriter(); XmlWriter _Writer = XmlWriter.Create(_StringWriter); x.Serialize(_Writer, _Order); string _Xml = _StringWriter.ToString(); return(Ok(_Xml)); }
public IHttpActionResult GetOrder(int id) { OrderSet _Order = db.OrderSet.Find(id); if (_Order == null) { return(NotFound()); } System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_Order.GetType()); var _StringWriter = new StringWriter(); XmlWriter _Writer = XmlWriter.Create(_StringWriter); x.Serialize(_Writer, _Order); string _Xml = _StringWriter.ToString(); return(Ok(_Xml)); }
public IHttpActionResult PostOrder([FromBody] OrderSet orderSet) { // OrderSet orderSet = new OrderSet(); OrderTreatment _treatment = new OrderTreatment(); List <Product> Products = new List <Product>(); //orderSet =request; foreach (var _item in db.OrderLineSet) { orderSet.OrderLineSet.Add(_item); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_treatment.Validation(ref orderSet, ref Products)) { _treatment.Insert(orderSet); } else { } System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(orderSet.GetType()); var _StringWriter = new StringWriter(); XmlWriter _Writer = XmlWriter.Create(_StringWriter); x.Serialize(_Writer, orderSet); string _Xml = _StringWriter.ToString(); return(CreatedAtRoute("DefaultApi", new { id = orderSet.IdOrder }, _Xml)); }