public async Task <IActionResult> DeleteConfirmed(int id)
        {
            // First Delete All Entries Where Employees Were Assigned to Project
            var emps = _context.ProjectAssignments.Where(a => a.ProjKey == id);
            // And Delete All the Scopes
            var scopes = _context.Scopes.Where(P => P.ProjectId == id);

            // If there are emps
            // Remove Each One

            foreach (var p in emps)
            {
                _context.Remove(p);
            }
            // Update the Db
            await _context.SaveChangesAsync();

            // There is at least one Scope associated with a Project
            foreach (var s in scopes)
            {
                _context.Remove(s);
            }

            await _context.SaveChangesAsync();


            // Then Delete the project
            var projectModel = await _context.ProjectModel.SingleOrDefaultAsync(m => m.ID == id);

            _context.ProjectModel.Remove(projectModel);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(AllProjectsPartial)));
        }
        public ActionResult DeleteConfirm(int id, Project projectModel)
        {
            db.Remove(projectModel);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            var proj = context.Projects.Where(x => x.Id == id).FirstOrDefault();

            context.Remove(proj);
            context.SaveChanges();
            return(View(proj));
        }
예제 #4
0
        public IActionResult Delete(Student student)
        {
            student = _context.Students.Find(student.Id);

            _context.Remove(student);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
예제 #5
0
        public IActionResult Delete(Department department)
        {
            department = _context.Departments.Find(department.Id);

            _context.Remove(department);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
예제 #6
0
        public ActionResult DeleteConfirm(int id, Project projectModel)
        {
            var proj = context
                       .Projects
                       .Where(p => p.Id == id)
                       .FirstOrDefault();

            context.Remove(proj);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }