示例#1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            Session["token"] = null;
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            ServiceIntegration.AuthenticationService authentication = new ServiceIntegration.AuthenticationService();
            ServiceIntegration.ClientService         client         = new ClientService();
            string token = await authentication.authentication(model.Email, model.Password);

            if (token != "")
            {
                Session["token"] = token;

                Client clientDesactualizado = new Client();
                clientDesactualizado.CL_NAME = model.Email;
                Client clientActualizado = await client.GetClient(token, clientDesactualizado);

                Session["username"] = model.Email;
                Session["clientId"] = clientActualizado.CL_ID;

                return(RedirectToLocal(returnUrl));
            }
            else
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
        public async Task <ActionResult> Index()
        {
            ClientService service = new ClientService();

            ServiceIntegration.AuthenticationService authentication = new ServiceIntegration.AuthenticationService();

            string token = await authentication.authentication(ConfigurationManager.AppSettings["AdminUser"].ToString(), ConfigurationManager.AppSettings["AdminPassword"].ToString());

            Session["token"] = token;
            List <ClientFAccount> clients = await service.GetClients(token);

            return(View(clients));
        }