Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("For get list item press '1',for create list item press '2',for update list item press '3',for delete list item press '4' ");
            string a = Console.ReadLine();

            if (a == "1")
            {
                CsomGetListItem g = new CsomGetListItem();
                g.GetListItem();
            }
            else if (a == "2")
            {
                CsomCreate c = new CsomCreate();
                c.Create();
            }
            else if (a == "3")
            {
                CsomUpdate u = new CsomUpdate();
                u.Update();
            }
            else if (a == "4")
            {
                CsomDelete d = new CsomDelete();
                d.Delete();
            }
            else
            {
                Console.WriteLine("Please press 1,2,3 or 4 !");
                Program p = new Program();
            }
        }
Exemplo n.º 2
0
        public void Delete()
        {
            User usr = new User();

            CsomGetListItem g = new CsomGetListItem();

            Console.Write("Please enter the deleted list item ID=");
            int id = Convert.ToInt32(Console.ReadLine());

            ListItem listItem = usr.userList.GetItemById(id);

            listItem.DeleteObject();

            usr.context.ExecuteQuery();
        }
Exemplo n.º 3
0
        public void Update()
        {
            User usr = new User();

            CsomGetListItem g = new CsomGetListItem();

            Console.Write("Please enter the updated list item ID=");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.Write("Please enter the Title=");
            string title = Console.ReadLine();

            Console.Write("Please enter the UserAge=");
            int UserAge = Convert.ToInt32(Console.ReadLine());

            Console.Write("Please enter the UserCity=");
            string usercity = Console.ReadLine();

            Console.Write("Please enter the UserCountry=");
            string usercountry = Console.ReadLine();

            Console.Write("Please enter the UserName="******"Please enter the UserNumber=");
            int usernumber = Convert.ToInt32(Console.ReadLine());
            // Assume there is a list item with ID=1.
            ListItem listItem = usr.userList.GetItemById(id);

            listItem["Title"]       = title;
            listItem["UserAge"]     = UserAge;
            listItem["UserCity"]    = usercity;
            listItem["UserCountry"] = usercountry;
            listItem["UserName1"]   = username;
            listItem["UserNumber"]  = UserAge;
            listItem.Update();

            usr.context.ExecuteQuery();
            Console.WriteLine("Succesfully Updated...");
            Console.Read();
        }