Esempio n. 1
0
        private void DeletePerson <Type>(DbSet <Type> people, string userId) where Type : Person
        {
            var person = people.FirstOrDefault(p => p.SystemUser.Id == userId);
            var entry  = context.Entry <Type>(person);

            entry.State = EntityState.Deleted;
            context.SaveChanges();
        }
Esempio n. 2
0
        public IActionResult DeleteDepartment(int departmentId)
        {
            var dep   = drugstore.Departments.First(d => d.ID == departmentId);
            var entry = drugstore.Entry <Department>(dep);

            entry.State = EntityState.Deleted;
            drugstore.SaveChanges();
            return(RedirectToAction("Departments"));
        }