public IHttpActionResult PutVaccinationReservation(int id, VaccinationReservation vaccinationReservation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vaccinationReservation.VaccReservation_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public string GetDelete(int DId)
        {
            VaccinationReservation healthcareReservation = db.VaccinationReservations.Find(DId);

            healthcareReservation.VaccReservation_isDeleted = true;
            db.SaveChanges();
            return("success");
        }
        public ActionResult DeleteConfirmed(int id)
        {
            VaccinationReservation vaccinationReservation = db.VaccinationReservations.Find(id);

            db.VaccinationReservations.Remove(vaccinationReservation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult PostVaccinationReservation(VaccinationReservation vaccinationReservation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.VaccinationReservations.Add(vaccinationReservation);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = vaccinationReservation.VaccReservation_id }, vaccinationReservation));
        }
 public ActionResult Edit([Bind(Include = "VaccReservation_id,VaccReservation_HealthCare_id,VaccReservation_Citizen_id,VaccReservation_child_id,VaccReservation_date,VaccReservation_checked,VaccReservation_Code,VaccReservation_VaccinationType_id,VaccReservation_isDeleted,VaccReservation_cancel,TransactionDate")] VaccinationReservation vaccinationReservation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vaccinationReservation).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.VaccReservation_Citizen_id         = new SelectList(db.Citizens, "citizen_id", "citizen_national_id", vaccinationReservation.VaccReservation_Citizen_id);
     ViewBag.VaccReservation_HealthCare_id      = new SelectList(db.HealthCares, "hospital_id", "hospital_name", vaccinationReservation.VaccReservation_HealthCare_id);
     ViewBag.VaccReservation_VaccinationType_id = new SelectList(db.VaccinationTypes, "vaccination_type_id", "vaccination_type_name", vaccinationReservation.VaccReservation_VaccinationType_id);
     return(View(vaccinationReservation));
 }
        public IHttpActionResult DeleteVaccinationReservation(int id)
        {
            VaccinationReservation vaccinationReservation = db.VaccinationReservations.Find(id);

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

            db.VaccinationReservations.Remove(vaccinationReservation);
            db.SaveChanges();

            return(Ok(vaccinationReservation));
        }
        // GET: VaccinationReservations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VaccinationReservation vaccinationReservation = db.VaccinationReservations.Find(id);

            if (vaccinationReservation == null)
            {
                return(HttpNotFound());
            }
            return(View(vaccinationReservation));
        }
        // GET: VaccinationReservations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VaccinationReservation vaccinationReservation = db.VaccinationReservations.Find(id);

            if (vaccinationReservation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.VaccReservation_Citizen_id         = new SelectList(db.Citizens, "citizen_id", "citizen_national_id", vaccinationReservation.VaccReservation_Citizen_id);
            ViewBag.VaccReservation_HealthCare_id      = new SelectList(db.HealthCares, "hospital_id", "hospital_name", vaccinationReservation.VaccReservation_HealthCare_id);
            ViewBag.VaccReservation_VaccinationType_id = new SelectList(db.VaccinationTypes, "vaccination_type_id", "vaccination_type_name", vaccinationReservation.VaccReservation_VaccinationType_id);
            return(View(vaccinationReservation));
        }
        // POST: doctorReservation/Delete/5
        //delete of admin page
        public ActionResult DeleteConfirmedUser(int?id)
        {
            var data = db.VaccinationReservations.Where(a => a.VaccReservation_isDeleted != true && a.VaccReservation_id == id && a.VaccReservation_date > DateTime.Now).SingleOrDefault();

            if (data == null)
            {
                ViewBag.err = "old reservation can not be canceled";
                if (Session["lang"] != null)
                {
                    if (Session["lang"].ToString().Equals("ar-EG"))
                    {
                        ViewBag.err = "لا يمكن الغاء حجز قديم";
                    }
                }
                var data1 = db.VaccinationReservations.Where(a => a.VaccReservation_isDeleted != true && a.VaccReservation_id == id).Include(v => v.Citizen).Include(a => a.Citizen.Citizen1).Include(v => v.HealthCare).Include(v => v.VaccinationType).SingleOrDefault();

                return(View(data1));
            }
            VaccinationReservation vacc = db.VaccinationReservations.Find(id);

            vacc.VaccReservation_isDeleted = true;
            db.SaveChanges();
            return(RedirectToAction("IndexUser"));
        }
        public ActionResult Edit(VaccinationReservation vaccinationReservation, int schedule, int VaccType)
        {
            var old = db.VaccinationReservations.Find(vaccinationReservation.VaccReservation_id);

            ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

            ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
            ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
            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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                    ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                }
            }

            //---------------------------------------------------------------------
            var CitizenAge = db.Citizens.Find(vaccinationReservation.VaccReservation_Citizen_id).citizen_birthDate;
            var AgeonVacc  = db.VaccinationTypes.Find(VaccType);

            if (AgeonVacc != null)
            {
                int?     vaccday = AgeonVacc.vaccination_type_period + 60;
                TimeSpan t       = vaccinationReservation.VaccReservation_date.Value.Subtract(Convert.ToDateTime(CitizenAge));

                if (t.Days > vaccday || t.Days < AgeonVacc.vaccination_type_period)
                {
                    ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                    ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                    ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                    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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                            ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                        }
                    }
                    ViewBag.vcc = Servicely.Languages.Language.Vaccination_not_allowed_to_the_child;
                    return(View());
                }
            }

            int?reservationmax = db.ScheduleVaccinations.Find(schedule).checkup_number;

            int maxreserv = db.ScheduleVaccReservationM_M.Where(a => a.ScheduleVaccReservation_schedule_id == schedule).Join(db.VaccinationReservations, a => a.ScheduleVaccReservation_reservationVacc_id, b => b.VaccReservation_id, (a, b) => new { b }).Where(a => a.b.VaccReservation_date == vaccinationReservation.VaccReservation_date).Count();

            if (maxreserv == reservationmax)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.day_is_full_choose_another_date;
                return(View());
            }



            var data = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_VaccinationType_id == VaccType && a.VaccReservation_checked == true && a.VaccReservation_date < DateTime.Now).FirstOrDefault();

            if (data != null)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.your_child_is_vaccinated;
                return(View());
            }
            var data1 = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_VaccinationType_id == VaccType && a.VaccReservation_date >= DateTime.Now).FirstOrDefault();

            if (data1 != null)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.you_have_already_reservation;
                return(View());
            }



            old.VaccReservation_HealthCare_id      = vaccinationReservation.VaccReservation_HealthCare_id;
            old.VaccReservation_date               = vaccinationReservation.VaccReservation_date;
            old.VaccReservation_Citizen_id         = vaccinationReservation.VaccReservation_Citizen_id;
            old.VaccReservation_VaccinationType_id = VaccType;

            db.SaveChanges();


            return(RedirectToAction("IndexUser"));
        }
        public ActionResult Create(VaccinationReservation vaccinationReservation, int schedule, int VaccType)
        {
            ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

            ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
            ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");

            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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                    ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                }
            }
            int cid = (int)Session["citizenID"];

            vaccinationReservation.VaccReservation_VaccinationType_id = VaccType;
            vaccinationReservation.VaccReservation_Citizen_id         = cid;
            vaccinationReservation.VaccReservation_date = db.ScheduleVaccinations.Find(schedule).checkup_date;

            //---------------------------------------------------------------------
            var CitizenAge = db.Citizens.Find(vaccinationReservation.VaccReservation_child_id).citizen_birthDate;
            var AgeonVacc  = db.VaccinationTypes.Find(VaccType);
            //if (AgeonVacc != null)
            //{
            //    int? vaccday = AgeonVacc.vaccination_type_period + 60;
            //    TimeSpan t = db.ScheduleVaccinations.Find(schedule).checkup_date.Value.Subtract(Convert.ToDateTime(CitizenAge));

            //    if (t.Days > vaccday || t.Days < AgeonVacc.vaccination_type_period)
            //    {
            //        ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

            //        ViewBag.HCtype = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
            //        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");

            //        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.HCtype = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
            //        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");


            //            }
            //        }

            //        ViewBag.vcc =Servicely.Languages.Language.Vaccination_not_allowed_to_the_child;
            //        return View();

            //    }
            //}

            int?reservationmax = db.ScheduleVaccinations.Find(schedule).checkup_number;

            int maxreserv = db.ScheduleVaccReservationM_M.Where(a => a.ScheduleVaccReservation_schedule_id == schedule).Join(db.VaccinationReservations, a => a.ScheduleVaccReservation_reservationVacc_id, b => b.VaccReservation_id, (a, b) => new { b }).Where(a => a.b.VaccReservation_isDeleted != true && a.b.VaccReservation_date == vaccinationReservation.VaccReservation_date && a.b.VaccReservation_HealthCare_id == vaccinationReservation.VaccReservation_HealthCare_id && a.b.VaccReservation_VaccinationType_id == VaccType && a.b.VaccReservation_cancel != true).Count();

            if (maxreserv == reservationmax)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");

                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.day_is_full_choose_another_date;
                return(View());
            }



            var data = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_VaccinationType_id == VaccType && a.VaccReservation_checked == true && a.VaccReservation_date < DateTime.Now).FirstOrDefault();

            if (data != null)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.your_child_is_vaccinated;
                return(View());
            }
            var data1 = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_child_id == vaccinationReservation.VaccReservation_child_id && a.VaccReservation_VaccinationType_id == vaccinationReservation.VaccReservation_VaccinationType_id && ((a.VaccReservation_date.Value.Year >= DateTime.Now.Year && a.VaccReservation_date.Value.Month > DateTime.Now.Month) || (a.VaccReservation_date.Value.Year >= DateTime.Now.Year && a.VaccReservation_date.Value.Month == DateTime.Now.Month && a.VaccReservation_date.Value.Day >= DateTime.Now.Day)) && a.VaccReservation_cancel != true && a.VaccReservation_isDeleted != true).FirstOrDefault();

            if (data1 != null)
            {
                ViewBag.State = new SelectList(db.States.Where(a => a.state_isDeleted != true), "state_id", "state_name");

                ViewBag.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name");
                ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name");
                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.HCtype   = new SelectList(db.HealthCare_Type.Where(a => a.healthcare_isDeleted != true), "healthcare_type_id", "healthcare_type_name_arabic");
                        ViewBag.VaccType = new SelectList(db.VaccinationTypes.Where(a => a.vaccination_isDeleted != true), "vaccination_type_id", "vaccination_type_name_arabic");
                    }
                }
                ViewBag.vcc = Servicely.Languages.Language.you_are_already_reserved_on_this_day;
                return(View());
            }

            string cod = Guid.NewGuid().ToString().Substring(0, 5) + "-" + Guid.NewGuid().ToString().Substring(0, 5);

            vaccinationReservation.VaccReservation_Code    = cod;
            vaccinationReservation.VaccReservation_checked = false;
            vaccinationReservation.TransactionDate         = DateTime.Now;
            db.VaccinationReservations.Add(vaccinationReservation);
            db.SaveChanges();
            ScheduleVaccReservationM_M mm = new ScheduleVaccReservationM_M();

            mm.ScheduleVaccReservation_reservationVacc_id = vaccinationReservation.VaccReservation_id;
            mm.ScheduleVaccReservation_schedule_id        = schedule;
            db.ScheduleVaccReservationM_M.Add(mm);
            db.SaveChanges();

            var father = db.Citizens.Find(cid);
            var child  = db.Citizens.Find(vaccinationReservation.VaccReservation_child_id);
            // var address = db.Addresses.Where(a => a.address_isCurrent == true).Join(db.AddressCitizens, a => a.address_id, b => b.CA_AddressId, (a, b) => b).Where(a => a.CA_CitizenId == itemm.citizen_id).Select(a => a.Address.address_district_id).SingleOrDefault();
            //var hospital = db.HealthCares.Where(a => a.hospital_district_id == address).FirstOrDefault();
            var vaccSchedule = db.ScheduleVaccM_M.Where(a => a.scheduleVacc_vaccType_id == vaccinationReservation.VaccReservation_VaccinationType_id).Join(db.ScheduleVaccinations, a => a.scheduleVacc_schedule_id, b => b.schedule_id, (a, b) => new { b }).FirstOrDefault();
            var email        = db.Contacts.Where(a => a.contact_citizen_id == cid).Join(db.Contact_Type, a => a.contact_contactType_id, b => b.contact_type_id, (a, b) => new { a, b }).Where(b => b.b.contact_type_name == "Email").Select(a => a.a).FirstOrDefault();
            int code         = maxreserv;
            var HealthCare   = db.HealthCares.Find(vaccinationReservation.VaccReservation_HealthCare_id);

            if (email != null)
            {
                //string Title = "Dear " + father.citizen_first_name + " " + father.citizen_second_name + " " + father.citizen_third_name + " " + father.citizen_fourth_name + " \n  " +
                //  "You have reserved an appointment to your chilled " + child.citizen_first_name + "( " + child.citizen_national_id + " ) on " + vaccSchedule.b.checkup_date.Value.ToShortDateString()+" from : "+ vaccSchedule.b.checkup_start +"to : "+ vaccSchedule.b.checkup_end + " \n\n" +
                //  " Health Care Name: "+HealthCare.hospital_name+" \n Health Care Address: "+HealthCare.District.Region.City.State.state_name +" "+ HealthCare.District.Region.City.city_name + " " + HealthCare.District.Region.region_name + " " + HealthCare.District.district_name + " \n" +"Reservation Code: "
                //   +( code+=1 ) + " \n yours sincerely , ";
                //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                //smtp.EnableSsl = true;
                //smtp.UseDefaultCredentials = false;
                //smtp.Credentials = new NetworkCredential("*****@*****.**", "csce4502f16");
                //smtp.Send("*****@*****.**", email.contact_data, "Vaccination", Title);
                ViewBag.vcc = Servicely.Languages.Language.successfully_reserved_checkemail;
                return(View());
            }



            ViewBag.vcc = Servicely.Languages.Language.successfully_reserved;
            return(View());
        }
Exemple #12
0
        public string PostVaccinationReservation(vacc vaccinationReservation)
        {
            var CitizenAge = db.Citizens.Find(vaccinationReservation.VaccReservation_Citizen_id).citizen_birthDate;
            var AgeonVacc  = db.VaccinationTypes.Find(vaccinationReservation.VaccReservation_VaccinationType_id);



            vaccinationReservation.VaccReservation_date      = db.ScheduleVaccinations.Find(vaccinationReservation.schedule).checkup_date;
            vaccinationReservation.VaccReservation_isDeleted = false;



            //---------------------------------------------------------------------



            int?reservationmax = db.ScheduleVaccinations.Find(vaccinationReservation.schedule).checkup_number;

            int maxreserv = db.ScheduleVaccReservationM_M.Where(a => a.ScheduleVaccReservation_schedule_id == vaccinationReservation.schedule).Join(db.VaccinationReservations, a => a.ScheduleVaccReservation_reservationVacc_id, b => b.VaccReservation_id, (a, b) => new { b }).Where(a => a.b.VaccReservation_VaccinationType_id == vaccinationReservation.VaccReservation_VaccinationType_id && a.b.VaccReservation_date == vaccinationReservation.VaccReservation_date && a.b.VaccReservation_HealthCare_id == vaccinationReservation.VaccReservation_HealthCare_id && a.b.VaccReservation_cancel != true).Count();

            if (maxreserv == reservationmax)
            {
                return(Servicely.Languages.Language.day_is_full_choose_another_date);
            }



            var data = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_VaccinationType_id == vaccinationReservation.VaccReservation_VaccinationType_id && a.VaccReservation_checked == true && a.VaccReservation_date < DateTime.Now).FirstOrDefault();

            if (data != null)
            {
                return(Servicely.Languages.Language.your_child_is_vaccinated);
            }
            var data1 = db.VaccinationReservations.Where(a => a.VaccReservation_Citizen_id == vaccinationReservation.VaccReservation_Citizen_id && a.VaccReservation_child_id == vaccinationReservation.VaccReservation_child_id && a.VaccReservation_VaccinationType_id == vaccinationReservation.VaccReservation_VaccinationType_id && ((a.VaccReservation_date.Value.Year >= DateTime.Now.Year && a.VaccReservation_date.Value.Month > DateTime.Now.Month) || (a.VaccReservation_date.Value.Year >= DateTime.Now.Year && a.VaccReservation_date.Value.Month == DateTime.Now.Month && a.VaccReservation_date.Value.Day >= DateTime.Now.Day)) && a.VaccReservation_cancel != true && a.VaccReservation_isDeleted != true).FirstOrDefault();

            if (data1 != null)
            {
                return(Servicely.Languages.Language.you_are_already_reserved_on_this_day);
            }

            string cod = Guid.NewGuid().ToString().Substring(0, 5) + "-" + Guid.NewGuid().ToString().Substring(0, 5);

            VaccinationReservation vv = new VaccinationReservation();

            vv.VaccReservation_child_id           = vaccinationReservation.VaccReservation_child_id;
            vv.VaccReservation_Citizen_id         = vaccinationReservation.VaccReservation_Citizen_id;
            vv.VaccReservation_HealthCare_id      = vaccinationReservation.VaccReservation_HealthCare_id;
            vv.VaccReservation_VaccinationType_id = vaccinationReservation.VaccReservation_VaccinationType_id;
            vv.VaccReservation_date    = vaccinationReservation.VaccReservation_date;
            vv.VaccReservation_cancel  = false;
            vv.VaccReservation_Code    = cod;
            vv.VaccReservation_checked = false;
            vv.TransactionDate         = DateTime.Now;
            db.VaccinationReservations.Add(vv);
            db.SaveChanges();
            ScheduleVaccReservationM_M mm = new ScheduleVaccReservationM_M();

            mm.ScheduleVaccReservation_reservationVacc_id = vv.VaccReservation_id;
            mm.ScheduleVaccReservation_schedule_id        = vaccinationReservation.schedule;
            db.ScheduleVaccReservationM_M.Add(mm);
            db.SaveChanges();

            var father = db.Citizens.Find(vaccinationReservation.VaccReservation_Citizen_id);
            var child  = db.Citizens.Find(vaccinationReservation.VaccReservation_child_id);
            // var address = db.Addresses.Where(a => a.address_isCurrent == true).Join(db.AddressCitizens, a => a.address_id, b => b.CA_AddressId, (a, b) => b).Where(a => a.CA_CitizenId == itemm.citizen_id).Select(a => a.Address.address_district_id).SingleOrDefault();
            //var hospital = db.HealthCares.Where(a => a.hospital_district_id == address).FirstOrDefault();
            var vaccSchedule = db.ScheduleVaccM_M.Where(a => a.scheduleVacc_vaccType_id == vaccinationReservation.VaccReservation_VaccinationType_id).Join(db.ScheduleVaccinations, a => a.scheduleVacc_schedule_id, b => b.schedule_id, (a, b) => new { b }).FirstOrDefault();
            var email        = db.Contacts.Where(a => a.contact_citizen_id == vaccinationReservation.VaccReservation_Citizen_id).Join(db.Contact_Type, a => a.contact_contactType_id, b => b.contact_type_id, (a, b) => new { a, b }).Where(b => b.b.contact_type_name == "Email").Select(a => a.a).FirstOrDefault();
            int code         = maxreserv;
            var HealthCare   = db.HealthCares.Find(vaccinationReservation.VaccReservation_HealthCare_id);

            //if (email != null)
            //{
            //    //string Title = "Dear " + father.citizen_first_name + " " + father.citizen_second_name + " " + father.citizen_third_name + " " + father.citizen_fourth_name + " \n  " +
            //    //  "You have reserved an appointment to your chilled " + child.citizen_first_name + "( " + child.citizen_national_id + " ) on " + vaccSchedule.b.checkup_date.Value.ToShortDateString() + " from : " + vaccSchedule.b.checkup_start + "to : " + vaccSchedule.b.checkup_end + " \n\n" +
            //    //  " Health Care Name: " + HealthCare.hospital_name + " \n Health Care Address: " + HealthCare.District.Region.City.State.state_name + " " + HealthCare.District.Region.City.city_name + " " + HealthCare.District.Region.region_name + " " + HealthCare.District.district_name + " \n" + "Reservation Code: "
            //    //   + (code += 1) + " \n yours sincerely , ";
            //    //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
            //    //smtp.EnableSsl = true;
            //    //smtp.UseDefaultCredentials = false;
            //    //smtp.Credentials = new NetworkCredential("*****@*****.**", "csce4502f16");
            //    //smtp.Send("*****@*****.**", email.contact_data, "Vaccination", "Dear " + father.citizen_first_name + " " + father.citizen_second_name + " " + father.citizen_third_name + " " + father.citizen_fourth_name + " \n  " +
            //    //  "You have reserved an appointment to your chilled " + child.citizen_first_name + "( " + child.citizen_national_id + " ) on " + vaccSchedule.b.checkup_date.Value.ToShortDateString() + " from : " + vaccSchedule.b.checkup_start + "to : " + vaccSchedule.b.checkup_end + " \n\n" +
            //    //  " Health Care Name: " + HealthCare.hospital_name + " \n Health Care Address: " + HealthCare.District.Region.City.State.state_name + " " + HealthCare.District.Region.City.city_name + " " + HealthCare.District.Region.region_name + " " + HealthCare.District.district_name + " \n" + "Reservation Code: "
            //    //   + (code += 1) + " \n yours sincerely , ");


            //    return Servicely.Languages.Language.successfully_reserved_checkemail;
            //}



            return(Servicely.Languages.Language.successfully_reserved);
        }