示例#1
0
        public void CanDeleteEmployee()
        {
            var employee = _repository.FindOne(x => x.FirstName == "UpdateTest");

            var result = _repository.Delete(employee);

            Assert.NotNull(result);
        }
示例#2
0
        public ActionResult Delete(int id)
        {
            EmployeesRepository repo = new EmployeesRepository();

            repo.Delete(id);

            return(RedirectToAction("Index", "Employees"));
        }
示例#3
0
        public void Delete(ObjectListView olv)
        {
            var obj = olv.SelectedObject as Employee;

            using (EmployeesRepository repo = new EmployeesRepository())
            {
                repo.Delete(obj);
                olv.RemoveObject(obj);
            }
        }
        public ActionResult Delete(int id)
        {
            if (ModelState.IsValid)
            {
                repository.Delete(id);
            }


            return(RedirectToAction("Index", "Home"));
        }
示例#5
0
 public ActionResult Delete(int id, EmployeeModel model)
 {
     try
     {
         // TODO: Add delete logic here
         employees.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
示例#6
0
        public void EmployeesRepositoryTests_Delete()
        {
            EmployeesRepository repository = new EmployeesRepository();
            var employees = new Employees()
            {
                Account = "Tom"
            };

            repository.Delete("Tom");
            var result = repository.GetByEmployeesAccount("Tom");

            Assert.IsTrue(result.Account == null);
        }
示例#7
0
        public ActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest(_translationService.Translate(Request.Headers, "EC7")));
            }

            try
            {
                _employeesRepository.Delete(id);
                _employeesRepository.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest(_translationService.TranslateException(ex, Request.Headers)));
            }

            return(Ok(id));
        }
示例#8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            EmployeesRepository repository = new EmployeesRepository();

            try
            {
                repository.Delete(new SqlParameter("FirstName", txtFirstName.Text),
                                  new SqlParameter("LastName", txtLastName.Text),
                                  new SqlParameter("Role", txtRole.Text),
                                  new SqlParameter("Salary", txtSalary.Text)
                                  );
                DialogResult = DialogResult.OK;

                MessageBox.Show("მონაცემები წაშლილია");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public ActionResult Delete(int id, Employee employee)
        {
            if (id != employee.Id)
            {
                return(BadRequest());
            }

            if (_repository.GetById(id) == null)
            {
                return(NotFound());
            }

            try
            {
                _repository.Delete(employee);
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(employee));
            }
        }