public ActionResult DeleteConfirmed(string id)
        {
            Exposed_Infant exposed_Infant = db.Exposed_Infants.Find(id);

            db.Exposed_Infants.Remove(exposed_Infant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Exposed_Infant/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Exposed_Infant exposed_Infant = db.Exposed_Infants.Find(id);

            if (exposed_Infant == null)
            {
                return(HttpNotFound());
            }
            return(View(exposed_Infant));
        }
        // GET: Exposed_Infant/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Exposed_Infant exposed_Infant = db.Exposed_Infants.Find(id);

            if (exposed_Infant == null)
            {
                return(HttpNotFound());
            }
            ViewBag.NIN = new SelectList(db.Demographics, "NIN", "Full_Name", exposed_Infant.NIN);
            ViewBag.PID = new SelectList(db.Patients, "PID", "Full_Name", exposed_Infant.PID);
            return(View(exposed_Infant));
        }
        public ActionResult Create([Bind(Include = "EEID,NIN,PID,Infant_Feeding_Practices,HIV_Test,Results_Attempts")] Exposed_Infant exposed_Infant)
        {
            var    query = db.Exposed_Infants.Count() + 1;
            string temp  = "EXP-" + query;
            bool   exist = false;

            try
            {
                var search = db.Exposed_Infants.Where(c => c.EEID == temp).Single();
                exist = true;
            }
            catch
            {
                exist = false;
            }
            if (exist)
            {
                var all = db.Exposed_Infants.ToList();
                var exp = all.Last();
                exposed_Infant.EEID = "EXP-" + +DataModels.DataProcess.NextNumber(exp.EEID);
            }
            else
            {
                exposed_Infant.EEID = temp;
            }


            if (ModelState.IsValid)
            {
                if (DataModels.DataProcess.ComparePatientWithNIN(exposed_Infant.NIN, exposed_Infant.PID) == true)
                {
                    ModelState.AddModelError("", "Patient and Infant can't be the same person");
                }
                else
                {
                    db.Exposed_Infants.Add(exposed_Infant);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.NIN = new SelectList(db.Demographics, "NIN", "Full_Name", exposed_Infant.NIN);
            ViewBag.PID = new SelectList(db.Patients, "PID", "Full_Name", exposed_Infant.PID);
            return(View(exposed_Infant));
        }
 public ActionResult Edit([Bind(Include = "EEID,NIN,PID,Infant_Feeding_Practices,HIV_Test,Results_Attempts")] Exposed_Infant exposed_Infant)
 {
     if (ModelState.IsValid)
     {
         if (DataModels.DataProcess.ComparePatientWithNIN(exposed_Infant.NIN, exposed_Infant.PID) == true)
         {
             ModelState.AddModelError("", "Patient and Infant can't be the same person");
         }
         else
         {
             db.Entry(exposed_Infant).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.NIN = new SelectList(db.Demographics, "NIN", "Full_Name", exposed_Infant.NIN);
     ViewBag.PID = new SelectList(db.Patients, "PID", "Full_Name", exposed_Infant.PID);
     return(View(exposed_Infant));
 }