public async Task <IActionResult> Edit(int id, [Bind("TreamentProductId,ProductDose,TreatmentId,ProductId")] PtsTreamentProduct ptsTreamentProduct) { if (id != ptsTreamentProduct.TreamentProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ptsTreamentProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PtsTreamentProductExists(ptsTreamentProduct.TreamentProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.PtsProduct, "ProductId", "ProductName", ptsTreamentProduct.ProductId); ViewData["TreatmentId"] = new SelectList(_context.PtsTreatment, "TreatmentId", "TreatmentId", ptsTreamentProduct.TreatmentId); return(View(ptsTreamentProduct)); }
public async Task <IActionResult> Create([Bind("TreamentProductId,ProductDose,TreatmentId,ProductId")] PtsTreamentProduct ptsTreamentProduct) { if (ModelState.IsValid) { _context.Add(ptsTreamentProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.PtsProduct, "ProductId", "ProductName", ptsTreamentProduct.ProductId); ViewData["TreatmentId"] = new SelectList(_context.PtsTreatment, "TreatmentId", "TreatmentId", ptsTreamentProduct.TreatmentId); return(View(ptsTreamentProduct)); }