static void Main(string[] args) { ListicusRestClient client = new ListicusRestClient(); List list = new List{Name = "ClientList1"}; client.CreateList(list); Console.WriteLine(XmlSerializerHelper.SerializeToString(list)); }
public List CreateList(List list) { if (!list.Links.HasItems()) return null; context.Lists.Add(list); context.SaveChanges(); return list; }
private static void AddLinkModelToList(LinkModel linkModel, List list) { if (linkModel != null && linkModel.Url.IsValidUrl()) { if (list.Links == null) list.Links = new List<Link>(); Link link = linkModel.CreateLink(); list.Links.Add(link); } }
public static List CreateList(this ListModel model) { var list = new List {Id = model.Id.ToLongOrDefault(), Name = model.Name.ToNullOrValue()}; if (model.Links != null) { foreach (LinkModel linkModel in model.Links) { AddLinkModelToList(linkModel, list); } } return list; }
// public List<List> GetAllLists() // { // // } public List CreateList(List list) { var serializer = new XmlSerializer(typeof(List), "http://schemas.listicus.com"); HttpClient client = new HttpClient(); string listXml = XmlSerializerHelper.SerializeToString(serializer, list); HttpResponseMessage returnValue = client.Post(ListicusRestUrl, "text/xml", HttpContent.Create(listXml)); if (returnValue.StatusCode == HttpStatusCode.OK) { List returnedOrder = XmlSerializerHelper.DeserializeString<List>(serializer, returnValue.Content.ReadAsString()); return returnedOrder; } else { throw new HttpResponseError(returnValue.StatusCode, returnValue.Content.ReadAsString()); } }
public ActionResult Index(List list) { ListLogic listLogic = new ListLogic(); return new ObjectResult<List>(listLogic.CreateList(list)); }