Beispiel #1
0
        public ActionResult Create(ActivitiesViewModel activities)
        {
            if (ModelState.IsValid)
            {
                if (activities.titleList?.Length > 0)
                {
                    foreach (var item in activities.titleList)
                    {
                        Employees_Titles titles = new Employees_Titles
                        {
                            EmployeeID = activities.Employees.EmployeeID,
                            TitleID    = item
                        };

                        db.Employees_Titles.Add(titles);
                    }

                    db.Employees.Add(activities.Employees);
                }

                db.SaveChanges();
                return(RedirectToAction("Employees", "AdminManager"));
            }

            return(View(activities));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Employees_Titles employees_Titles = db.Employees_Titles.Find(id);

            db.Employees_Titles.Remove(employees_Titles);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "EmployeeTitleID,TitleID,EmployeeID")] Employees_Titles employees_Titles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employees_Titles).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "Name", employees_Titles.EmployeeID);
     ViewBag.TitleID    = new SelectList(db.Titles, "TitleID", "Name", employees_Titles.TitleID);
     return(View(employees_Titles));
 }
        // GET: Employees_Titles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employees_Titles employees_Titles = db.Employees_Titles.Find(id);

            if (employees_Titles == null)
            {
                return(HttpNotFound());
            }
            return(View(employees_Titles));
        }
        // GET: Employees_Titles/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employees_Titles employees_Titles = db.Employees_Titles.Find(id);

            if (employees_Titles == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "Name", employees_Titles.EmployeeID);
            ViewBag.TitleID    = new SelectList(db.Titles, "TitleID", "Name", employees_Titles.TitleID);
            return(View(employees_Titles));
        }