// GET: Backend/ProdWashing public ActionResult Index(int id) { ProductWashingVIewModel pwvm = new ProductWashingVIewModel(); var pd = db.Products.Find(id); pwvm.ProductID = pd.ProductID; pwvm.ProductName = pd.ProductName; ViewBag.productwashing = db.Washings; return(View(pwvm)); }
public ActionResult ProdWashingJson(int id) { List <ProductWashingVIewModel> pwvmlist = new List <ProductWashingVIewModel>(); var pw = db.ProductWashings.Where(x => x.ProductID == id).OrderByDescending(x => x.ProductWashingID); var ws = db.Washings; foreach (var item in pw) { ProductWashingVIewModel pwvm = new ProductWashingVIewModel { ProductWashingID = item.ProductWashingID, ProductID = item.ProductID, WashingID = item.WashingID, CreateDate = item.CreateDate, WashingName = ws.Where(x => x.WashingID == item.WashingID).FirstOrDefault().WashingName, }; pwvmlist.Add(pwvm); } return(Json(pwvmlist, JsonRequestBehavior.AllowGet)); }