Beispiel #1
0
        public HRListViewModel GetUsers(string url)
        {
            if (!url.Contains("playtech.corp"))
            {
                return(null);
            }
            var users = new HRListViewModel();

            var client = new WebClient
            {
                Encoding = Encoding.UTF8
            };

            XmlUrlResolver res = new XmlUrlResolver();

            res.Credentials = new NetworkCredential("foxsec", "SepaPada890", "EE"); //full user name: domain\\username

            XmlReaderSettings set = new XmlReaderSettings();

            set.XmlResolver = res;

            var doc = XDocument.Load(XmlReader.Create(url, set));

            //oldcode var doc = XDocument.Load(url);
            XNamespace space = XNamespace.Get("http://playtech.com/ISservices/");

            var usr = (from u in doc.Descendants(space + "FoxsecData")
                       select new HRItem
            {
                Id = Int32.Parse(u.Element(space + "EmployeeID").Value),
                Name = u.Element(space + "FirstName").Value,
                LastName = u.Element(space + "LastName").Value,
                Department = u.Element(space + "CostCenterName").Value,
                LastDateOfWork = u.Element(space + "TerminationDate").Value,
                CompanyName = u.Element(space + "CompanyName").Value
            }).ToList();

            //var client1 = new WebClient
            //{
            //    Encoding = Encoding.UTF8
            //};
            // var doc1 = XDocument.Load("https://bi.ptts.com/globalhrapi/report?country=ALL");
            //usr.AddRange(from u in doc1.Descendants("EmployeeDetails")
            //             select new HRItem
            //             {
            //                 Id = Int32.Parse(u.Element("EmployeeID").Value),
            //                 Name = u.Element("FirstName").Value,
            //                 LastName = u.Element("LastName").Value,
            //                 Department = u.Element("Department").Value,
            //                 LastDateOfWork = u.Element("LastDayOfWork").Value,
            //                 CompanyName = u.Element("Company").Value
            //             });

            users.HRItems = usr;
            return(users);
        }
Beispiel #2
0
        public async Task <IActionResult> Index(int id)
        {
            if (!User.Identity.IsAuthenticated || !User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            HRListViewModel model = new HRListViewModel
            {
                Users = _context.User.Where(x => x.Role.Name != "Admin").ToList(),
                Offer = _context.JobOffer.FirstOrDefault(x => x.Id == id)
            };

            return(View(model));
        }