// Get : Edit public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } List <Products> products = null; Appointments appointments = null; if (orm == 1) { products = qdb.p_join_psa((int)id); qdb.include_pt_st(products); appointments = qdb.retAppointment((int)id); } else { products = (from i in _db.Products join j in _db.ProductsSelectedForAppointments on i.Id equals j.ProductId where j.AppointmentId == id select i ).Include(e => e.ProductTypes).ToList(); appointments = (from i in _db.Appointments where i.Id == (int)id select i).FirstOrDefault(); } //var appointment = (from i in _db.Appointments where i.Id == (int) id select i).FirstOrDefault(); var applicationUsers = (from i in _db.ApplicationUsers select i).ToList(); AppointmentDetailViewModel avm = new AppointmentDetailViewModel() { Appointments = appointments, ApplicationUsers = applicationUsers, Products = products }; return(View(avm)); }