public IHttpActionResult SavePatient([FromBody] Patient patient)
        {
            TBLPATIENT         dbpatient;
            IList <TBLPATIENT> lstPatients;

            if (IsPatientExist(patient))
            {
                return(BadRequest("Duplicate Patient !!!"));
            }
            else
            {
                lstPatients = new List <TBLPATIENT>();
                dbpatient   = new TBLPATIENT
                {
                    Name    = patient.Name,
                    SurName = patient.SurName,
                    DOB     = patient.DOB,
                    CityId  = patient.CityId,
                    Gender  = patient.Gender
                };
                lstPatients.Add(dbpatient);
                DBContext.SaveAll(lstPatients);
                return(Ok("Patient Data saved !!!"));
            }
        }
Ejemplo n.º 2
0
 public bool SavePatient(TBLPATIENT tBLPATIENT)
 {
     if (Patients.Any(x => x.Name == tBLPATIENT.Name && x.SurName == tBLPATIENT.SurName))
     {
         throw new Exception("Records Exists");
     }
     Patients.Add(tBLPATIENT);
     return(true);
 }
 public void Post([FromBody] TBLPATIENT value)
 {
     if (_service.SavePatient(value))
     {
         Ok("Data saved");
     }
     else
     {
         throw new ArgumentException("Data not saved for value :" + value.Name + value.SurName);
     }
 }
Ejemplo n.º 4
0
        public bool SavePatient(TBLPATIENT tBLPATIENT)
        {
            var aa = new List <TBLPATIENT>();

            aa.Add(tBLPATIENT);
            if (GetPatients().Any(x => x.Gender == tBLPATIENT.Gender && x.Name == tBLPATIENT.Name &&
                                  x.SurName == tBLPATIENT.SurName && x.DOB == tBLPATIENT.DOB))
            {
                throw new Exception("Record already Exists");
            }
            return(DBContext.SaveAll <TBLPATIENT>(aa));
        }
Ejemplo n.º 5
0
        // Done
        protected void PatientDataGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            patientid = Convert.ToInt32(PatientDataGrid.DataKeys[e.RowIndex].Values["patient_ID"].ToString());

            if (patientid != 0)
            {
                using (ClinicManagementSystemDataContext dbcontext = new ClinicManagementSystemDataContext())
                {
                    TBLPATIENT patient = dbcontext.TBLPATIENTs.SingleOrDefault(p => p.patient_ID == patientid);
                    dbcontext.TBLPATIENTs.DeleteOnSubmit(patient);
                    dbcontext.SubmitChanges();
                    GetPatientData();
                }
            }
        }
        public IActionResult PostPatient([FromBody] TBLPATIENT patient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            List <TBLPATIENT> patientList = new List <TBLPATIENT>();

            patientList.Add(patient);

            DBContext.SaveAll <iMedOneDB.Models.TBLPATIENT>(patientList);

            return(Ok());
        }
Ejemplo n.º 7
0
        public void PostTestPatients()
        {
            var        controller = new PatientsController();
            TBLPATIENT tBLPATIENT = new TBLPATIENT();

            tBLPATIENT.Id      = 3;
            tBLPATIENT.Name    = "David";
            tBLPATIENT.SurName = "Marta";
            tBLPATIENT.Gender  = "M";
            tBLPATIENT.DOB     = System.DateTime.Parse("1992-06-24T00:00:00");

            var result   = controller.PostPatient(tBLPATIENT);
            var okResult = result as StatusCodeResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
Ejemplo n.º 8
0
        public void TestSavePatients()
        {
            TBLPATIENT dt = new TBLPATIENT();

            dt.Name    = "james";
            dt.SurName = "bond";
            dt.Gender  = "M";
            dt.DOB     = new System.DateTime(1980, 12, 9);
            var oo = service.SavePatient(dt);

            foreach (var item in service.GetPatients())
            {
                if (dt.Name == "james")
                {
                    Assert.AreSame(dt, item);
                }
            }

            Assert.IsTrue(oo);
        }
        private void InsertPatient()
        {
            using (ClinicManagementSystemDataContext dbcontext = new ClinicManagementSystemDataContext())
            {
                TBLPATIENT newPatient = new TBLPATIENT()
                {
                    patient_Name      = Patient_NameTB.Text,
                    patient_Gender    = GenderDropDownList.SelectedValue,
                    patient_BirthDate = PatientBirthTB.Text,
                    /* patient_BirthDate = DateTime.Parse(PatientBirth.Text),*/
                    patient_Height  = Patient_Height.Text,
                    patient_Weight  = Int32.Parse(Patient_Weight.Text),
                    patient_Phone   = Patient_Phone.Text,
                    patient_Email   = Patient_EAddressTB.Text,
                    patient_Address = PatientAddressTB.Text
                };

                dbcontext.TBLPATIENTs.InsertOnSubmit(newPatient);
                dbcontext.SubmitChanges();
            }
        }
Ejemplo n.º 10
0
 public void SavePatient(TBLPATIENT patient)
 {
     DBContext.SaveAll(new List <TBLPATIENT> {
         patient
     });
 }
Ejemplo n.º 11
0
 public static Patient MapTblPatientIntoPatient(TBLPATIENT patient)
 {
     return(mapper.Map <TBLPATIENT, Patient>(patient));
 }