public ActionResult EventDetails() { EventsServices serviceObj = new EventsServices(); EventDetailsViewModel obj = new EventDetailsViewModel(); obj.EventSubType = new List <string>(); obj.eventDetails = new List <AboutEvent>(); var Aboutevent1 = serviceObj.GetAllEvents(SessionToken).Entity.Where(x => x.EventStatus == 1).Select(x => x).ToList(); foreach (var item in Aboutevent1) { obj.EventSubType.Add(serviceObj.Geteventsubtype(SessionToken).Entity.Where(x => x.Id == item.SubTypeOfEvent).Select(x => x) == null ? null : serviceObj.Geteventsubtype(SessionToken).Entity.FirstOrDefault(x => x.Id == item.SubTypeOfEvent).EventSubType); } obj.eventDetails.AddRange(Aboutevent1); return(View(obj)); }