public ActionResult Delete(int id)
        {
            var currentUser = users.GetList().FirstOrDefault(u => u.Id == id);

            if (currentUser != null)
            {
                users.Delete(currentUser);
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
        private void btn_DeleteUser_Click(object sender, EventArgs e)
        {
            var user = dataGridView1.CurrentRow.DataBoundItem as User;

            var form = new DeleteUser();

            if (form.ShowDialog() == DialogResult.OK && (user != null))
            {
                userBL.Delete(user);
                DisplayUsers();
            }
        }
Пример #3
0
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                await UsersBL.Delete(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                ModelState.AddModelError("", "No se pudo eliminar este usuario");
                var user = UsersBL.Details(id);
                return(View(user));
            }
        }
Пример #4
0
        private static void DeleteUser()
        {
            try
            {
                Users   e  = new Users();
                UsersBL bl = new UsersBL();

                bool dltd = bl.Delete(e, "Ra12");
                if (dltd)
                {
                    Console.WriteLine("Deleted Succesfully");
                }
                else
                {
                    Console.WriteLine("not succesfully deleted");
                }
            }
            catch (UniversityException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }