public ActionResult DeleteConfirmed(int id)
        {
            SAILORTest SAILORTest = db.SAILORTests.Find(id);

            db.SAILORTests.Remove(SAILORTest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult AddNewPAtient(int id = 0)
        {
            SAILORTest rand = db.SAILORTests.Find(id);

            if (rand == null)
            {
                return(HttpNotFound());
            }
            return(View(rand));
        }
        //
        // GET: /randSAILORTest/Details/5

        public ActionResult Details(int id = 0)
        {
            SAILORTest SAILORTest = db.SAILORTests.Find(id);

            if (SAILORTest == null)
            {
                return(HttpNotFound());
            }
            return(View(SAILORTest));
        }
 public ActionResult Edit(SAILORTest SAILORTest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(SAILORTest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(SAILORTest));
 }
        // GET: /Model/Result/5
        public ActionResult Result(int RandID = 0)
        {
            SAILORTest rand = db.SAILORTests.Find(RandID);

            if (rand == null)
            {
                return(HttpNotFound());
            }
            return(View(rand));
        }
        public ActionResult Create(SAILORTest SAILORTest)
        {
            if (ModelState.IsValid)
            {
                db.SAILORTests.Add(SAILORTest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(SAILORTest));
        }
        public ActionResult Result([Bind(Include = "RandAllocation")] SAILORTest rand)
        {
            if (ModelState.IsValid)
            {
                rand.RandDate        = DateTime.UtcNow;
                db.Entry(rand).State = EntityState.Modified;
                db.SaveChanges();

                //email.EmailAddress = "*****@*****.**";
                //email.Name = "Mihaela";
                //email.RandAllocation = rand.RandAllocation;
                //email.RandID = rand.RandID;
                //email.Send();
            }
            return(View(rand));
        }
        public ActionResult AddNewPAtient
            ([Bind(Include = "RandID, ScreeningID, RandomisedBy,SiteID,SITE, ParticipantInitials, Age, Gender, Incl,Excl, ApproveMedical,ConsentDate, RandAllocation, RandMethod")] SAILORTest rand)
        {
            if (ModelState.IsValid)
            {
                //Random Number
                rand.RandDate = DateTime.Today;
                rand.RandTime = DateTime.Now;
                // Test test=new Test();
                rand.RandMethod = rand.RandMethod;
                //rand.SiteID = rand.SiteID;

                //rand.ConsentDate < DateTime.Now;

                db.Entry(rand).State = EntityState.Modified;
                //db.SaveChanges();


                try
                {
                    // return db.SaveChanges();


                    db.SaveChanges();
                }

                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        //foreach (var validationError in validationErrors.ValidationErrors)
                        //{
                        //    Trace.TraceInformation("Property: {0} Error: {1}",
                        //                            validationError.PropertyName,
                        //                            validationError.ErrorMessage);
                        //}
                    }
                }

                return(RedirectToAction("Result", rand));
            }

            return(View(rand));
        }