예제 #1
0
        public ActionResult SaveTNA(TNA tNA)
        {
            var    TNAInDb    = _context.TNAs.SingleOrDefault(t => t.StaffID == tNA.StaffID);
            Person userperson = _context.People.SingleOrDefault(p => p.ID == 0);

            if (TNAInDb == null)
            {
                TNAInDb         = new Models.TNA();
                TNAInDb.StaffID = tNA.StaffID;
                TNAInDb.Creator = userperson;
                TNAInDb.Created = DateTime.Now;
                _context.TNAs.Add(TNAInDb);
            }

            TNAInDb.DateReceived   = tNA.DateReceived;
            TNAInDb.TrainerID      = tNA.TrainerID;
            TNAInDb.ContactDate    = tNA.ContactDate;
            TNAInDb.ContactOutcome = tNA.ContactOutcome;
            TNAInDb.OutcomeID      = tNA.OutcomeID;
            TNAInDb.Modified       = DateTime.Now;
            TNAInDb.Modifier       = userperson;

            _context.SaveChanges();

            return(RedirectToAction("Index", "Person"));
        }
예제 #2
0
        public ActionResult TNA(int id)
        {
            var person = _context.People.SingleOrDefault(p => p.ID == id);

            if (person == null)
            {
                return(HttpNotFound());
            }
            ViewBag.person = person;
            TNA TNA = person.TNA;

            if (TNA == null)
            {
                TNA         = new TNA();
                TNA.StaffID = person.ID;
            }

            var TrainerList = _context.People.Where(p => p.Flags.Any(f => f.ID == "TRN"))
                              .Select(p => new Trainer {
                ID = p.ID, FName = p.Forename, SName = p.Surname
            })
                              .ToList();

            ViewBag.TrainerID = new SelectList(TrainerList, "ID", "Name");
            ViewBag.OutcomeID = new SelectList(_context.Statuses.Where(s => s.TNA_OUT), "ID", "StatusDesc");

            return(View(TNA));
        }