Link to home
Start Free TrialLog in
Avatar of Stacie
StacieFlag for United States of America

asked on

The name 'xyz' does not exist in the current context

I'm getting the following error: The name does not exist in the current context. in the following 2 lines bellow after I implement my if else statement. Not sure if there is a better way to write this ifelse statement as a tenary statement...

            var resultsContainer = GetReportResultsObject(searchCriteria, LoggedInUser, systemCultureInfo);
            var resultsContainer2 = GetReportResultsObject2(searchCriteria2, LoggedInUser, systemCultureInfo);


public ActionResult GenerateReportFromCache(string guidToken)
        {
            var objResponse = MemoryCache.Default.Get(guidToken) as ResponseObject;
            
            if (objResponse.Model.GetType().Equals(typeof(xxx.Models.CustomReports.DailyTechnicianRecapSearchCriteria)))
            {
                var searchCriteria = objResponse.Model as DailyEmployeeRecapSearchCriteria;
            }
            else
            {
                var searchCriteria2 = objResponse.Model as DailyTechnicianRecapSearchCriteria;
            }
           
           var systemCultureInfo = (System.Globalization.CultureInfo)ViewBag.SystemCultureInfo;

            var resultsContainer = GetReportResultsObject(searchCriteria, LoggedInUser, systemCultureInfo);
            var resultsContainer2 = GetReportResultsObject2(searchCriteria2, LoggedInUser, systemCultureInfo);


            XtraReport mainReport = new XtraReport();
            if (searchCriteria.ReportByTechnician)
            {
                DailyTechnicianRecapSearchCriteria techCriteria = new DailyTechnicianRecapSearchCriteria();
                techCriteria.Map(searchCriteria);
                techCriteria.FavoriteReportName = CustomReportsNames.DailyTechnicianRecap;
                mainReport = BuildTechnicianReportObject(techCriteria, LoggedInUser, systemCultureInfo);
            }
            else
            {
                searchCriteria.FavoriteReportName = CustomReportsNames.DailyEmployeeRecap;
                BuildReportObject(searchCriteria, LoggedInUser, systemCultureInfo, ref mainReport);
            }

            return GenerateReport(mainReport, searchCriteria.PreviewFlag);
        }

Open in new window

SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stacie

ASKER

Yes that is my problem.. The logic is wrong.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial