Exemplo n.º 1
0
        public IHttpActionResult PutVacinationHealthCareM_M(int id, VacinationHealthCareM_M vacinationHealthCareM_M)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vacinationHealthCareM_M.vaccinationhealthcare_id)
            {
                return(BadRequest());
            }

            //db.Entry(vacinationHealthCareM_M).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VacinationHealthCareM_MExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetVacinationHealthCareM_M(int id)
        {
            VacinationHealthCareM_M vacinationHealthCareM_M = db.VacinationHealthCareM_M.Find(id);

            if (vacinationHealthCareM_M == null)
            {
                return(NotFound());
            }

            return(Ok(vacinationHealthCareM_M));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostVacinationHealthCareM_M(VacinationHealthCareM_M vacinationHealthCareM_M)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.VacinationHealthCareM_M.Add(vacinationHealthCareM_M);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = vacinationHealthCareM_M.vaccinationhealthcare_id }, vacinationHealthCareM_M));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteVacinationHealthCareM_M(int id)
        {
            VacinationHealthCareM_M vacinationHealthCareM_M = db.VacinationHealthCareM_M.Find(id);

            if (vacinationHealthCareM_M == null)
            {
                return(NotFound());
            }

            db.VacinationHealthCareM_M.Remove(vacinationHealthCareM_M);
            db.SaveChanges();

            return(Ok(vacinationHealthCareM_M));
        }
Exemplo n.º 5
0
        public ActionResult Create(HealthCare hospital, List <int?> vacinationhealthcare_vaccination, List <int> hospitalSpecialization_specialization_id)
        {
            if (ModelState.IsValid)
            {
                var data = db.HealthCares.Where(a => a.hospital_name == hospital.hospital_name && a.hospital_district_id == hospital.hospital_district_id && a.hospital_isDeleted != true && a.healthcare_type_id == hospital.healthcare_type_id).SingleOrDefault();

                if (data != null)
                {
                    if (Session["lang"] != null)
                    {
                        if (Session["lang"].ToString().Equals("ar-EG"))
                        {
                            ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_arabic_name");
                            ViewBag.healthcare_type_id = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                            ViewBag.vacinationhealthcare_vaccination         = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                            ViewBag.hospitalSpecialization_specialization_id = new SelectList(db.HealthCareSpecializations.Where(a => a.specialization_isDeleted != true), "specialization_id", "specialization_name_arabic");
                            ViewBag.errhospital          = Languages.Language.errhospital;
                            ViewBag.hospital_district_id = new SelectList(db.Districts, "district_id", "district_name");
                            return(View(hospital));
                        }
                        else
                        {
                            ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");
                            ViewBag.healthcare_type_id = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                            ViewBag.vacinationhealthcare_vaccination         = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                            ViewBag.hospitalSpecialization_specialization_id = new SelectList(db.HealthCareSpecializations.Where(a => a.specialization_isDeleted != true), "specialization_id", "specialization_name");
                            ViewBag.errhospital          = Languages.Language.errhospital;
                            ViewBag.hospital_district_id = new SelectList(db.Districts, "district_id", "district_name");
                            return(View(hospital));
                        }
                    }
                    else
                    {
                        ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");
                        ViewBag.healthcare_type_id = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                        ViewBag.vacinationhealthcare_vaccination         = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                        ViewBag.hospitalSpecialization_specialization_id = new SelectList(db.HealthCareSpecializations.Where(a => a.specialization_isDeleted != true), "specialization_id", "specialization_name");
                        ViewBag.errhospital          = Languages.Language.errhospital;
                        ViewBag.hospital_district_id = new SelectList(db.Districts, "district_id", "district_name");
                        return(View(hospital));
                    }
                }
                db.HealthCares.Add(hospital);
                db.SaveChanges();
                if (vacinationhealthcare_vaccination != null)
                {
                    VacinationHealthCareM_M vaccinaate = new VacinationHealthCareM_M();
                    foreach (var item in vacinationhealthcare_vaccination)
                    {
                        vaccinaate.vaccinationhealthcare_hospital   = hospital.hospital_id;
                        vaccinaate.vacinationhealthcare_vaccination = item;
                        db.VacinationHealthCareM_M.Add(vaccinaate);
                        db.SaveChanges();
                    }
                }
                foreach (var item in hospitalSpecialization_specialization_id)
                {
                    HealthCareSpecializationM_M spec = new HealthCareSpecializationM_M();
                    spec.hospitalSpecialization_hospital_id       = hospital.hospital_id;
                    spec.hospitalSpecialization_specialization_id = item;
                    db.HealthCareSpecializationM_M.Add(spec);

                    db.SaveChanges();
                }



                return(RedirectToAction("Index"));
            }
            ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");
            ViewBag.healthcare_type_id = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
            ViewBag.vacinationhealthcare_vaccination         = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
            ViewBag.hospitalSpecialization_specialization_id = new SelectList(db.HealthCareSpecializations.Where(a => a.specialization_isDeleted != true), "specialization_id", "specialization_name");

            ViewBag.hospital_district_id = new SelectList(db.Districts, "district_id", "district_name", hospital.hospital_district_id);
            return(View(hospital));
        }