We help IT Professionals succeed at work.
Get Started

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

Stacie
Stacie asked
on
75 Views
Last Modified: 2018-11-28
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

Comment
Watch Question
Freelance programmer / Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 4 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE