예제 #1
0
        // GET: TestCoreValues/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestCoreValues testCoreValues = db.TestCoreValues.Find(id);

            if (testCoreValues == null)
            {
                return(HttpNotFound());
            }
            Guid userId;

            Guid.TryParse(User.Identity.GetUserId(), out userId);

            if (testCoreValues.recognizor == userId)
            {
                return(View(testCoreValues));
            }
            else
            {
                return(View("NotAuthenticated"));
            }
        }
예제 #2
0
        // GET: TestCoreValues/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestCoreValues testCoreValues = db.TestCoreValues.Find(id);

            if (testCoreValues == null)
            {
                return(HttpNotFound());
            }
            var recognizor = db.userData.OrderBy(c => c.lastName).ThenBy(c => c.firstName);

            ViewBag.recognized = new SelectList(recognizor, "ID", "fullName");

            Guid userId;

            Guid.TryParse(User.Identity.GetUserId(), out userId);

            if (testCoreValues.recognizor == userId)
            {
                return(View(testCoreValues));
            }
            else
            {
                return(View("NotAuthenticated"));
            }
        }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            TestCoreValues testCoreValues = db.TestCoreValues.Find(id);

            db.TestCoreValues.Remove(testCoreValues);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "ID,award,recognizor,recognized,recognitionDate,phone,title,description")] TestCoreValues testCoreValues)
        {
            if (ModelState.IsValid)
            {
                Guid memberID; // created a variable to hold GUID
                Guid.TryParse(User.Identity.GetUserId(), out memberID);
                testCoreValues.recognizor = memberID;

                db.TestCoreValues.Add(testCoreValues);
                db.SaveChanges();

                {
                    string notification     = "Nomination for a core value award sent to :<br/>";
                    var    personRecognized = db.userData.Find(testCoreValues.recognized);
                    var    fullName         = testCoreValues.personRecognized;
                    var    recognition      = testCoreValues.award;
                    var    email            = personRecognized.Email;
                    var    date             = testCoreValues.recognitionDate;
                    var    msg = "Hi " + fullName + ",\n\nWe wanted to inform you that you have been recognized for " + recognition;
                    msg          += " on " + date.ToShortDateString() + ".";
                    msg          += "\n\nCongratulations on being nominated for an award.";
                    msg          += "\n\nSincerely\nCentric Consulting Team";
                    notification += "<br/>" + fullName + " has been nominated for " + recognition + " on " + date.ToShortDateString() + ".";

                    MailMessage myMessage = new MailMessage();
                    MailAddress from      = new MailAddress("*****@*****.**", "SysAdmin");
                    myMessage.From = from;
                    myMessage.To.Add(email);
                    myMessage.Subject = "Congratulations on being nominated!";
                    myMessage.Body    = msg;
                    try
                    {
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host = "smtp.gmail.com";
                        smtp.Port = 587;
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "CentricTe@m4!");
                        smtp.EnableSsl             = true;
                        smtp.Send(myMessage);
                        TempData["mailError"] = "";
                    }
                    catch (Exception ex)
                    {
                        // this captures an exception and allows you to display the message in the View
                        TempData["mailError"] = ex.Message;
                        return(View("mailError"));
                    }
                    ViewBag.notification = notification;
                }
                return(RedirectToAction("Index"));
            }
            var recognizor = db.userData.OrderBy(c => c.lastName).ThenBy(c => c.firstName);

            ViewBag.recognizor = new SelectList(recognizor, "ID", "fullName");

            ViewBag.recognized = new SelectList(recognizor, "ID", "fullName");
            return(View(testCoreValues));
        }
예제 #5
0
        // GET: TestCoreValues/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestCoreValues testCoreValues = db.TestCoreValues.Find(id);

            if (testCoreValues == null)
            {
                return(HttpNotFound());
            }
            var recognizor = db.userData.OrderBy(c => c.lastName).ThenBy(c => c.firstName);

            ViewBag.recognizor = new SelectList(recognizor, "ID", "fullName");

            string     recId      = User.Identity.GetUserId();
            SelectList recognized = new SelectList(db.userData, "ID", "fullName");

            recognized         = new SelectList(recognized.Where(x => x.Value != recId).ToList(), "Value", "Text");
            ViewBag.recognized = recognized;


            var rec     = db.TestCoreValues.Where(r => r.ID == id);
            var recList = rec.ToList();

            ViewBag.rec = recList;

            var totalCount = recList.Count(); //counts all the recognitions for that person

            var rec1Cnt = recList.Where(r => r.award == TestCoreValues.CoreValue.Excellence).Count();
            //counts all the excellance recongitions
            //notice how the Enum values are references, class.enum.value
            //the next two lines show another way to do the same counting
            var rec2Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Integrity);
            var rec3Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Stewardship);
            var rec4Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Culture);
            var rec5Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Commitment);
            var rec6Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Innovation);
            var rec7Cnt = recList.Count(r => r.award == TestCoreValues.CoreValue.Balance);

            //copy the values into the ViewBag
            ViewBag.total       = totalCount;
            ViewBag.Excellance  = rec1Cnt;
            ViewBag.Integrity   = rec2Cnt;
            ViewBag.Stewardship = rec3Cnt;
            ViewBag.Culture     = rec4Cnt;
            ViewBag.Commitment  = rec5Cnt;
            ViewBag.Innovation  = rec6Cnt;
            ViewBag.Balance     = rec7Cnt;

            return(View(testCoreValues));
        }
예제 #6
0
        public ActionResult Edit([Bind(Include = "ID,award,recognizor,recognized,recognitionDate,phone,title,description")] TestCoreValues testCoreValues)
        {
            if (ModelState.IsValid)
            {
                Guid memberID; // created a variable to hold GUID
                Guid.TryParse(User.Identity.GetUserId(), out memberID);
                testCoreValues.recognizor      = memberID;
                db.Entry(testCoreValues).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var recognizor = db.userData.OrderBy(c => c.lastName).ThenBy(c => c.firstName);

            ViewBag.recognizor = new SelectList(recognizor, "ID", "fullName");

            ViewBag.recognized = new SelectList(recognizor, "ID", "fullName");


            return(View(testCoreValues));
        }