Example #1
0
 public Medicines AddMedicine(Medicines medicine)
 {
     medicine.Id = Guid.NewGuid();
     _medicineContext.Medicines.Add(medicine);
     _medicineContext.SaveChanges();
     return(medicine);
 }
 public ActionResult Edit([Bind(Include = "id,M_Name,M_Company,M_Type,M_Potency,M_Details,M_Price")] Medicine medicine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medicine));
 }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Branch,Message,Email")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
        public ActionResult Create([Bind(Include = "Id,Producer,Price,Name")] Medicine medicine)
        {
            if (ModelState.IsValid)
            {
                db.Medicines.Add(medicine);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicine));
        }
        public ActionResult Create(Admin admin)
        {
            if (ModelState.IsValid)
            {
                db.Admins.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "id,U_Name,U_Contact,U_Address,TotalBill,OrderDate,PaymentMethod")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                db.Carts.Add(cart);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cart));
        }
Example #7
0
        public ActionResult <Patient> PostPatient([FromBody] Patient patient)
        {
            Patient oldPatient = _db.Find <Patient>(patient.Id);

            if (oldPatient != null)
            {
                return(BadRequest());
            }

            _db.Patients.Add(patient);
            _db.SaveChanges();

            return(Ok(patient));
        }
        public ActionResult <Parameter> PostParameter([FromBody] Parameter parameter)
        {
            Parameter oldParameter = _db.Find <Parameter>(parameter.Id);

            if (oldParameter != null)
            {
                return(BadRequest());
            }

            _db.Parameters.Add(parameter);
            _db.SaveChanges();

            return(Ok(parameter));
        }
 private static int SaveToDatabase <T>(T tObject)
 {
     using (MedicineContext db = new MedicineContext())
     {
         if (tObject is Diagnoses)
         {
             db.Diagnoses.Add(tObject as Diagnoses);
         }
         else if (tObject is Doctors)
         {
             db.Doctors.Add(tObject as Doctors);
         }
         else if (tObject is Patients)
         {
             db.Patients.Add(tObject as Patients);
         }
         else if (tObject is Diseases)
         {
             db.Diseases.Add(tObject as Diseases);
         }
         else
         {
             throw new TypeLoadException("Тип не распознан!");
         }
         return(db.SaveChanges());
     }
 }
        public ActionResult <Diagnosis> PostDiagnosis([FromBody] Diagnosis diagnosis)
        {
            Diagnosis oldDiagnosis = _db.Find <Diagnosis>(diagnosis.Id);

            if (oldDiagnosis != null)
            {
                return(BadRequest());
            }

            _db.Diagnoses.Add(diagnosis);
            _db.SaveChanges();

            return(Ok(diagnosis));
        }
        public ActionResult <Examination> PostExamination([FromBody] Examination examination)
        {
            Examination oldExamination = _db.Find <Examination>(examination.Id);

            if (oldExamination != null)
            {
                return(BadRequest());
            }

            _db.Examinations.Add(examination);
            _db.SaveChanges();

            return(Ok(examination));
        }
        public ActionResult Create(SignUp signUp)
        {
            if (ModelState.IsValid)
            {
                db.SignUps.Add(signUp);
                db.SaveChanges();
                return(RedirectToAction("Create", "Logins"));
            }

            return(View(signUp));
        }
 public JsonResult Delete(int id)
 {
     using (MedicineContext db = new MedicineContext())
     {
         Medicine medicine = db.Medicines.Find(id);
         if (medicine == null)
         {
             return(Json(new { success = false }));
         }
         db.Medicines.Remove(medicine);
         db.SaveChanges();
         return(Json(new { success = true }));
     }
 }
 private void AddPolice_button_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(police_textBox.Text))
     {
         using (MedicineContext db = new MedicineContext())
         {
             db.Policies.Add(new Policy()
             {
                 Name = police_textBox.Text
             });
             db.SaveChanges();
         }
         this.Close();
     }
 }
 public JsonResult Insert(Medicine medicine)
 {
     if (medicine != null)
     {
         using (MedicineContext db = new MedicineContext())
         {
             db.Medicines.Add(medicine);
             db.SaveChanges();
             return(Json(new { success = true }));
         }
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
 public JsonResult Update(Medicine updatedMedicine)
 {
     using (MedicineContext db = new MedicineContext())
     {
         Medicine existingMedicine = db.Medicines.Find(updatedMedicine.ID);
         if (existingMedicine == null)
         {
             return(Json(new { success = false }));
         }
         else
         {
             existingMedicine.Name     = updatedMedicine.Name;
             existingMedicine.Price    = updatedMedicine.Price;
             existingMedicine.Quantity = updatedMedicine.Quantity;
             db.SaveChanges();
             return(Json(new { success = true }));
         }
     }
 }
Example #17
0
        public ActionResult <Prescription> PostPrescription([FromBody] Prescription prescription)
        {
            Prescription oldPrescription = _db.Find <Prescription>(prescription.Id);

            if (oldPrescription != null)
            {
                return(BadRequest());
            }

            _db.Prescriptions.Add(prescription);
            _db.SaveChanges();

            return(Ok(prescription));
        }
Example #18
0
        private void DeleteCommandFun(object obj)
        {
            if (SelectedItem == null)
            {
                return;
            }

            if (MessageBox.Show(
                    "Вы точно хотите удалить запись?",
                    "Подтверждение",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question
                    ) != MessageBoxResult.Yes)
            {
                return;
            }

            db.Medicines.Remove(SelectedItem);
            MedicineList.Remove(SelectedItem);
            db.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "id,M_Name,Image,M_Company,M_Type,M_Potency,M_Details,M_Price")] Medicine medicine, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                Medicine        m  = new Medicine();
                MedicineContext db = new MedicineContext();
                m.Image     = Image.FileName.ToString();
                m.M_Name    = medicine.M_Name;
                m.M_Company = medicine.M_Company;
                m.M_Type    = medicine.M_Type;
                m.M_Potency = medicine.M_Potency;

                m.M_Details = medicine.M_Details;
                m.M_Price   = medicine.M_Price;
                var path = Server.MapPath("~/Content/img");
                Image.SaveAs(Path.Combine(path, Image.FileName.ToString()));
                db.Medicines.Add(m);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicine));
        }
        public ActionResult <Treatment> PostTreatment([FromBody] Treatment treatment)
        {
            Treatment oldTreatment = _db.Find <Treatment>(treatment.Id);

            if (oldTreatment != null)
            {
                return(BadRequest());
            }

            _db.Treatments.Add(treatment);
            _db.SaveChanges();

            return(Ok(treatment));
        }