public JsonResult GetJsonData(StandardUserModel model) { var submenufind = db.SpecialistTypeSubMenus.Where(x => x.SubMenuId == model.specialistTypesubmenu.SubMenuId).FirstOrDefault(); var waypointsfind = db.WayPoints.Where(x => x.Id == model.waypoints.Id).FirstOrDefault(); List <SpecialistModel> data = new List <SpecialistModel>(); List <SpecialistModel> specialistfirstlist = db.Specialists.Where(x => x.SubMenu == submenufind.SubMenuName && x.PostCode == waypointsfind.PostCode && x.State == waypointsfind.State && x.Suburbs == waypointsfind.Suburbs).ToList().Select(x => new SpecialistModel() { Latitude = waypointsfind.Latitude, Longitude = waypointsfind.Longitude, Title = x.Title, SpecialistName = x.SpecialistName, Surname = x.Surname, Address1 = x.Address1 + x.Address2, MobileNo = x.MobileNo, PhoneNo = x.PhoneNo, EmailAddress = x.EmailAddress, State = x.State, TakingNewPatients = x.TakingNewPatients, IsBooking = x.IsBooking, Waiting_Time = x.Waiting_Time, price = x.price, Suburbs = x.Suburbs }).ToList(); if (specialistfirstlist != null) { data = specialistfirstlist; } else { DbHandleWayPoints dvp = new DbHandleWayPoints(); WayPoint wp = dvp.GetNearestWayPoint(waypointsfind.Latitude, waypointsfind.Longitude); List <SpecialistModel> specialistsecondtlist = db.Specialists.Where(x => x.SubMenu == submenufind.SubMenuName && x.PostCode == wp.PostCode && x.State == wp.State && x.Suburbs == wp.Suburbs).ToList().Select(x => new SpecialistModel() { Latitude = wp.Latitude, Longitude = wp.Longitude, Title = x.Title, SpecialistName = x.SpecialistName, Surname = x.Surname, Address1 = x.Address1 + x.Address2, MobileNo = x.MobileNo, PhoneNo = x.PhoneNo, EmailAddress = x.EmailAddress, State = x.State, TakingNewPatients = x.TakingNewPatients, IsBooking = x.IsBooking, Waiting_Time = x.Waiting_Time, price = x.price, Suburbs = x.Suburbs }).ToList(); data = specialistsecondtlist; } // // // var submenu=model.waypoints.Id //var specialistmodel=db.Specialists.Where(x=>x.) // return(Json(data, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllSpecialist(StandardUserModel model) { // var contacts = db.Specialists.Where(x => x.SpecialistTypeId == x.SpecialistTypeId && x.State == model.waypoints.State && x.Suburbs == model.waypoints.Suburbs).Select(x => new { Id = x.SpecialistId, Name = x.SpecialistName, //model.specialistType. = x.MobileNumber }).ToList(); // <--- cast to list if GetUserContacts returns an IEnumerable return(Json(contacts, JsonRequestBehavior.AllowGet)); }