Beispiel #1
0
        public async Task <ActionResult <IEnumerable <BloodDB> > > AddPatient([FromBody] BloodDB patient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Data"));
            }
            try
            {
                _context.BloodDB.Add(patient);

                await _context.SaveChangesAsync();

                //new { id = patient.id, Name = patient.Name, Age = patient.Age, donor = patient.donor, address = patient.address, phoneNumber = patient.phoneNumber, bloodType = patient.bloodType, NHSNumber = patient.NHSNumber }
                //return CreatedAtAction(nameof(GetPatients), new { id = patient.id, Name = patient.Name, Age = patient.Age, donor = patient.donor, address = patient.address, phoneNumber = patient.phoneNumber, bloodType = patient.bloodType, NHSNumber = patient.NHSNumber });
                return(Ok("Successfully added " + patient.Name));
            } catch (Exception e)
            {
                return(BadRequest("Invalid Data"));
            }
        }