public async Task <IActionResult> Index(string org, string service, int reporteeId)
        {
            if (reporteeId == 0)
            {
                return(LocalRedirect($"/designer/{org}/{service}/ManualTesting/Users/"));
            }

            CheckAndUpdateWorkflowFile(org, service);
            RequestContext requestContext = RequestHelper.GetRequestContext(Request.Query, Guid.Empty);

            requestContext.UserContext = await _userHelper.CreateUserContextBasedOnReportee(HttpContext, reporteeId);

            requestContext.Reportee = requestContext.UserContext.Reportee;

            StartServiceModel startServiceModel = new StartServiceModel
            {
                ServiceID    = org + "_" + service,
                ReporteeList = _authorization.GetReporteeList(requestContext.UserContext.UserId)
                               .Select(x => new SelectListItem {
                    Text = x.ReporteeNumber + " " + x.ReporteeName, Value = x.PartyID.ToString()
                })
                               .ToList(),
                PrefillList = _testdata.GetServicePrefill(requestContext.Reportee.PartyId, org, service)
                              .Select(x => new SelectListItem {
                    Text = x.PrefillKey + " " + x.LastChanged, Value = x.PrefillKey
                })
                              .ToList(),
                ReporteeID = requestContext.Reportee.PartyId,
                Org        = org,
                Service    = service,
            };

            if (reporteeId != 0 && reporteeId != startServiceModel.ReporteeID && startServiceModel.ReporteeList.Any(r => r.Value.Equals(reporteeId.ToString())))
            {
                startServiceModel.ReporteeID = reporteeId;
                requestContext.Reportee      = await _register.GetParty(startServiceModel.ReporteeID);

                requestContext.UserContext.ReporteeId = reporteeId;
                requestContext.UserContext.Reportee   = requestContext.Reportee;
                HttpContext.Response.Cookies.Append("altinncorereportee", startServiceModel.ReporteeID.ToString());
            }

            List <ServiceInstance> formInstances = _testdata.GetFormInstances(requestContext.Reportee.PartyId, org, service);

            ViewBag.InstanceList = formInstances.OrderBy(r => r.LastChanged).ToList();

            return(View(startServiceModel));
        }
        public IActionResult Index(string org, string service, int reporteeId)
        {
            RequestContext requestContext = RequestHelper.GetRequestContext(Request.Query, 0);

            requestContext.UserContext = _userHelper.GetUserContext(HttpContext);
            requestContext.Reportee    = requestContext.UserContext.Reportee;

            var startServiceModel = new StartServiceModel
            {
                ServiceID    = org + "_" + service,
                ReporteeList = _authorization.GetReporteeList(requestContext.UserContext.UserId)
                               .Select(x => new SelectListItem {
                    Text = x.ReporteeNumber + " " + x.ReporteeName, Value = x.PartyID.ToString()
                })
                               .ToList(),
                PrefillList = _testdata.GetServicePrefill(requestContext.Reportee.PartyId, org, service)
                              .Select(x => new SelectListItem {
                    Text = x.PrefillKey + " " + x.LastChanged, Value = x.PrefillKey
                })
                              .ToList(),
                ReporteeID = requestContext.Reportee.PartyId
            };

            if (reporteeId != 0 && reporteeId != startServiceModel.ReporteeID && startServiceModel.ReporteeList.Any(r => r.Value.Equals(reporteeId.ToString())))
            {
                startServiceModel.ReporteeID          = reporteeId;
                requestContext.Reportee               = _register.GetParty(startServiceModel.ReporteeID);
                requestContext.UserContext.ReporteeId = reporteeId;
                requestContext.UserContext.Reportee   = requestContext.Reportee;
                HttpContext.Response.Cookies.Append("altinncorereportee", startServiceModel.ReporteeID.ToString());
            }

            List <ServiceInstance> formInstances = _testdata.GetFormInstances(requestContext.Reportee.PartyId, org, service);

            ViewBag.InstanceList = formInstances.OrderBy(r => r.LastChanged).ToList();

            return(View(startServiceModel));
        }
        public async Task <IActionResult> Index(string org, string service, int reporteeId)
        {
            var    developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext);
            string apiUrl    = _settings.GetRuntimeAPIPath("ZipAndSendRepo", org, service, developer);

            using (HttpClient client = AuthenticationHelper.GetDesignerHttpClient(_httpContextAccessor.HttpContext, _testdataRepositorySettings.GetDesignerHost()))
            {
                client.BaseAddress = new Uri(apiUrl);
                HttpResponseMessage response = await client.GetAsync(apiUrl);

                string zipPath     = $"{_settings.GetServicePath(org, service, developer)}{service}.zip";
                string extractPath = _settings.GetServicePath(org, service, developer);
                if (!Directory.Exists(extractPath))
                {
                    Directory.CreateDirectory(extractPath);
                }
                else
                {
                    Directory.Delete(extractPath, true);
                    Directory.CreateDirectory(extractPath);
                }

                using (Stream s = response.Content.ReadAsStreamAsync().Result)
                {
                    using (var w = System.IO.File.OpenWrite(zipPath))
                    {
                        s.CopyTo(w);
                    }
                }

                ZipFile.ExtractToDirectory(zipPath, extractPath);
            }

            RequestContext requestContext = RequestHelper.GetRequestContext(Request.Query, 0);

            requestContext.UserContext = _userHelper.GetUserContext(HttpContext);
            requestContext.Reportee    = requestContext.UserContext.Reportee;

            var startServiceModel = new StartServiceModel
            {
                ServiceID    = org + "_" + service,
                ReporteeList = _authorization.GetReporteeList(requestContext.UserContext.UserId)
                               .Select(x => new SelectListItem {
                    Text = x.ReporteeNumber + " " + x.ReporteeName, Value = x.PartyID.ToString()
                })
                               .ToList(),
                PrefillList = _testdata.GetServicePrefill(requestContext.Reportee.PartyId, org, service)
                              .Select(x => new SelectListItem {
                    Text = x.PrefillKey + " " + x.LastChanged, Value = x.PrefillKey
                })
                              .ToList(),
                ReporteeID = requestContext.Reportee.PartyId,
                Org        = org,
                Service    = service,
            };

            if (reporteeId != 0 && reporteeId != startServiceModel.ReporteeID && startServiceModel.ReporteeList.Any(r => r.Value.Equals(reporteeId.ToString())))
            {
                startServiceModel.ReporteeID          = reporteeId;
                requestContext.Reportee               = _register.GetParty(startServiceModel.ReporteeID);
                requestContext.UserContext.ReporteeId = reporteeId;
                requestContext.UserContext.Reportee   = requestContext.Reportee;
                HttpContext.Response.Cookies.Append("altinncorereportee", startServiceModel.ReporteeID.ToString());
            }

            List <ServiceInstance> formInstances = _testdata.GetFormInstances(requestContext.Reportee.PartyId, org, service, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));

            ViewBag.InstanceList = formInstances.OrderBy(r => r.LastChanged).ToList();

            return(View(startServiceModel));
        }
        public async Task <IActionResult> Index(string org, string app, int partyId, int userId)
        {
            if (userId == 0 || partyId == 0)
            {
                return(LocalRedirect($"/designer/{org}/{app}/ManualTesting/Users/"));
            }

            bool?isValidSelection = await _authorization.ValidateSelectedParty(userId, partyId);

            if (isValidSelection != true)
            {
                return(LocalRedirect($"/designer/{org}/{app}/ManualTesting/Users/"));
            }

            Response.Cookies.Append(
                _generalSettings.GetAltinnPartyCookieName,
                partyId.ToString(),
                new CookieOptions
            {
                Domain = _generalSettings.HostName
            });

            CheckAndUpdateWorkflowFile(org, app);
            RequestContext requestContext = RequestHelper.GetRequestContext(Request.Query, Guid.Empty);

            requestContext.UserContext = await _userHelper.CreateUserContextBasedOnUserAndParty(HttpContext, userId, partyId);

            requestContext.Party = requestContext.UserContext.Party;

            StartServiceModel startServiceModel = new StartServiceModel
            {
                ServiceID = org + "_" + app,
                PartyList = _authorization.GetPartyList(requestContext.UserContext.UserId)
                            .Select(x => new SelectListItem
                {
                    Text  = (x.PartyTypeName == PartyType.Person) ? x.SSN + " " + x.Name : x.OrgNumber + " " + x.Name,
                    Value = x.PartyId.ToString()
                })
                            .ToList(),
                PrefillList = _testdata.GetServicePrefill(requestContext.Party.PartyId, org, app)
                              .Select(x => new SelectListItem {
                    Text = x.PrefillKey + " " + x.LastChanged, Value = x.PrefillKey
                })
                              .ToList(),
                PartyId = requestContext.Party.PartyId,
                Org     = org,
                Service = app,
            };

            if (partyId != 0 && partyId != startServiceModel.PartyId && startServiceModel.PartyList.Any(r => r.Value.Equals(partyId.ToString())))
            {
                startServiceModel.PartyId = partyId;
                requestContext.Party      = await _register.GetParty(startServiceModel.PartyId);

                requestContext.UserContext.PartyId = partyId;
                requestContext.UserContext.Party   = requestContext.Party;
            }

            List <ServiceInstance> formInstances = _testdata.GetFormInstances(requestContext.Party.PartyId, org, app);

            ViewBag.InstanceList = formInstances.OrderBy(r => r.LastChanged).ToList();

            return(View(startServiceModel));
        }
Example #5
0
 public List <ServicePrefill> GetServicePrefill(string org, string service, string developer, int partyId)
 {
     return(_testdataSI.GetServicePrefill(partyId, org, service, developer));
 }