コード例 #1
0
        public ActionResult DeleteСleaning(int id)
        {
            Сleaning cl = _db.Сleaning.Find(id);

            _db.Сleaning.Remove(cl ?? throw new InvalidOperationException());
            _db.SaveChanges();
            return(RedirectToAction("Details/" + cl.IdEmployee));
        }
コード例 #2
0
        public ActionResult AddСleaning(int id)
        {
            Employee employee = _db.Employee.Find(id);
            Сleaning cleaning = new Сleaning
            {
                Employee   = employee,
                IdEmployee = employee.Id
            };

            ViewBag.IdDay   = new SelectList(_db.DaysWeek, "Id", "Day");
            ViewBag.IdFloor = new SelectList(_db.Floors, "Id", "Floor");
            return(View(cleaning));
        }
コード例 #3
0
        public ActionResult AddСleaning([Bind(Include = "Id,IdEmployee,IdFloor,IdDay")] Сleaning сleaning)
        {
            if (ModelState.IsValid)
            {
                _db.Сleaning.Add(сleaning);
                _db.SaveChanges();
                return(RedirectToAction("Details/" + сleaning.IdEmployee));
            }

            ViewBag.IdDay      = new SelectList(_db.DaysWeek, "Id", "Day", сleaning.IdDay);
            ViewBag.IdEmployee = new SelectList(_db.Employee, "Id", "Name", сleaning.IdEmployee);
            ViewBag.IdFloor    = new SelectList(_db.Floors, "Id", "Id", сleaning.IdFloor);
            return(View(сleaning));
        }