Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // POST: Diagnoses/Create
- // To protect from overposting attacks, please enable the specific properties you want to bind to, for
- // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
- [HttpPost]
- [ValidateAntiForgeryToken]
- public async Task<IActionResult> Create(Int32? patientId, DiagnosesCreateModel model)
- {
- if (patientId == null)
- {
- return this.NotFound();
- }
- var patient = await this._context.Patients.SingleOrDefaultAsync(x => x.Id == patientId);
- if (patient == null)
- {
- return this.NotFound();
- }
- if (ModelState.IsValid)
- {
- var diagnosis = new Diagnosis
- {
- PatientId = patient.Id,
- Type = model.Type,
- Complications = model.Complications,
- Details = model.Details
- };
- this._context.Add(diagnosis);
- await this._context.SaveChangesAsync();
- return this.RedirectToAction("Index", new { patientId = patient.Id });
- }
- this.ViewBag.Ward = patient;
- return this.View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement