예제 #1
0
파일: Program.cs 프로젝트: akhurst/listicus
 static void Main(string[] args)
 {
     ListicusRestClient client = new ListicusRestClient();
     List list = new List{Name = "ClientList1"};
     client.CreateList(list);
     Console.WriteLine(XmlSerializerHelper.SerializeToString(list));
 }
예제 #2
0
        public List CreateList(List list)
        {
            if (!list.Links.HasItems())
                return null;

            context.Lists.Add(list);
            context.SaveChanges();
            return list;
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
        }
예제 #5
0
 //        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());
     }
 }
예제 #6
0
 public ActionResult Index(List list)
 {
     ListLogic listLogic = new ListLogic();
     return new ObjectResult<List>(listLogic.CreateList(list));
 }