Ejemplo n.º 1
0
        private bool TryAuthorize(UserAccountViewModel viewModel)
        {
            viewModel.ParseToken();
            var userName = PXLogin.ConcatLogin(viewModel.Username, viewModel.Company);
            var retVal   = PXLogin.LoginUser(ref userName, viewModel.Password);

            if (retVal)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Index(UserAccountViewModel viewModel)
        {
            string content = "Not Authorized!";

            if (TryAuthorize(viewModel))
            {
                INSiteMaint siteMaint = PXGraph.CreateInstance <INSiteMaint>();
                var         sites     = siteMaint.site.Select().Select(pxResult => new INSiteViewModel {
                    Description = pxResult.Record.Descr, SiteCD = pxResult.Record.SiteCD
                }).ToList();
                var template = File.ReadAllText(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "Frames/IIG/Warehouses/Index.cshtml"));
                var model    = new { Sites = sites };
                content = Engine.Razor.RunCompile(template, "IIGINSiteIndex", null, model);
            }

            var response = new HttpResponseMessage();

            response.Content = new StringContent(content);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }