Avatar of Stacie
Stacie
Flag 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

.NET ProgrammingC#

Avatar of undefined
Last Comment
AndyAinscow

8/22/2022 - Mon