//Constructor injection public OrganizerDataViewModel(IHttpContextAccessor httpContext, IFlightSpannersData flightSpannersData) { string code = httpContext.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; //Return the organizer based on the code var organizer = flightSpannersData.GetOrganizerByCode(code); this.OrganizerCode = organizer.OrganizerCode; this.OrganizerEmail = organizer.OrganizerEmail; this.OrganizerFName = organizer.OrganizerFName; this.OrganizerLName = organizer.OrganizerLName; this.OrganizerM1Name = organizer.OrganizerM1Name; this.OrganizerM2Name = organizer.OrganizerM2Name; this.OrganizerMobile1 = organizer.OrganizerMobile1; this.OrganizerMobile2 = organizer.OrganizerMobile2; this.OrganizerOccupation = organizer.OrganizerOccupation; //Get the OrganizerGroupList item of the model using GetOrganizerGroupNames(code) method this.OrganizerGroupList = flightSpannersData.GetOrganizerGroupSelectListItems(code); //ViewBag.OrganizerGroupList = model.OrganizerGroupList; }