Ejemplo n.º 1
0
        public ActionResult Insert(Pandora.Model.Entities.Employee person)
        {
            ViewBag.ReportsTo = new SelectList(es.GetActive(), "ID", "EmployeeLabel", person.ReportsTo);

            if (ModelState.IsValid)
            {
                bool sonuc = es.Add(person);
                if (sonuc)
                {
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                ViewBag.Message = "Invalid format.";
            }

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Update(Pandora.Model.Entities.Employee person)
        {
            ViewBag.ReportsTo = new SelectList(es.GetActive(), "ID", "EmployeeLabel", person.ReportsTo);

            Pandora.Model.Entities.Employee toUpdate = es.GetByID(person.ID);
            toUpdate.FirstName = person.FirstName;
            toUpdate.LastName  = person.LastName;
            toUpdate.Title     = person.Title;
            toUpdate.Notes     = person.Notes;
            toUpdate.IsAdmin   = person.IsAdmin;
            toUpdate.Password  = person.Password;

            if (person.ReportsTo != null || person.EmployeeReportsTo != null)
            {
                toUpdate.ReportsTo = person.ReportsTo;
            }

            es.Update(toUpdate);

            return(RedirectToAction("Index"));
        }