예제 #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Patient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PatientExists(Patient.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            Prescription.patientID = patientID;

            if (PrescriptionExists(Prescription.patientID))
            {
                Prescription old = _context.Prescription.First(e => e.patientID == Prescription.patientID);
                Prescription.ID = old.ID;
                _context.Remove(old);
                _context.Attach(Prescription).State = EntityState.Modified;

                await _context.SaveChangesAsync();
            }
            else
            {
                _context.Prescription.Add(Prescription);
                await _context.SaveChangesAsync();
            }


            return(RedirectToPage("/Patients/History/MDPrescription", new { id = patientID }));
        }