public ActionResult AddMeds([Bind(Include = "Description, AlertThreshold, Vendor, Notes")] Medication meds)
        {
            ModelState["AppUser"].Errors.Clear();  //Required since ApplicationUser is NOT populated by the user in the view.

            try
            {
                if (ModelState.IsValid)
                {
                    //var userRec = db.Users.Find(User.Identity.GetUserId());
                    //var EmailAddress = userRec.Email;
                    //var x = userRec.Name;

                    meds.AppUser      = db.Users.Find(User.Identity.GetUserId()); //Requires "using Microsoft.AspNet.Identity;"
                    meds.CreatedDate  = DateTime.Now;
                    meds.ModifiedDate = DateTime.Now;                             //remove later
                    db.Medications.Add(meds);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException ex)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(meds));
        }
        public void LoadRows()
        {
            using (MedicineDB db = new MedicineDB())
            {
                UserTransaction trans1 = new UserTransaction
                {
                    Quantity      = 10,
                    CreatedByDate = new DateTime(2018, 04, 20),

                    //  CreatedByUser = new AppUser { Name = "Person1" },
                    //  ModifiedByUser = new AppUser { Name = "Person2" },
                    Med = new Medication {
                        Description = "Description One", AlertThreshold = 5
                    }
                };

                UserTransaction trans2 = new UserTransaction
                {
                    Quantity      = 10,
                    CreatedByDate = new DateTime(2018, 06, 10),

                    //  CreatedByUser = new AppUser { Name = "Person3" },
                    //  ModifiedByUser = new AppUser { Name = "Person4" },
                    Med = new Medication {
                        Description = "Description Two", AlertThreshold = 6
                    }
                };

                db.UserTransactions.Add(trans1);
                db.UserTransactions.Add(trans2);

                db.SaveChanges();
            }
        }
        public void AddTrans(Params prms)
        {
            MedicineDB db = new MedicineDB();

            UserTransaction UserTrans = new UserTransaction();


            IEnumerable <Medication> md = from m in db.Medications
                                          where m.ID == prms.ID
                                          select m;

            Medication med = md.ElementAt(0);


            UserTrans.Quantity      = prms.Quantity;
            UserTrans.CreatedByDate = DateTime.Now;
            UserTrans.CreatedById   = db.Users.Find(User.Identity.GetUserId());
            UserTrans.Med           = med;


            db.UserTransactions.Add(UserTrans);
            db.SaveChanges();
        }