Пример #1
0
 // GET: ComboItems/Create
 public ActionResult Create()
 {
     //in the get, a list of users to select is presented
     MyIdentityManager myIdentityManager = new MyIdentityManager();
     var allUsers = myIdentityManager.GetAllUsers();
     
     
     return View();
 }
        //called by API() 
        public ActionResult UsersToJson() { 
            MyIdentityManager myIdentityManager = new MyIdentityManager();
            var allUsers = myIdentityManager.GetAllUsers();
            List<string> usermanes = new List<string>();
            foreach (var applicationUser in allUsers) {
                usermanes.Add(applicationUser.UserName);
            }
 
            var serialized = JsonConvert.SerializeObject(usermanes);

            myIdentityManager.Dispose();
            return Content(serialized , typeof(Json).Name);
        }
        public ActionResult UsersToXml() { 
            string xml = "<?xml version = \"1.0\" encoding= \"utf-8\"?>";
            MyIdentityManager myIdentityManager = new MyIdentityManager();
            var users = myIdentityManager.GetAllUsers();
            xml = xml + "<Users>";
            foreach (var user in users) {
                xml = xml + "<Name>";
                xml = xml + user.Id;
                xml = xml + "</Name>";
            }
            xml = xml + "</Users>";

            myIdentityManager.Dispose();
            return Content(xml , "text/xml");
        }