Beispiel #1
0
        public ActionResult Delete(int ID)
        {
            var item = repo.Get單一筆部門資料(ID);

            repo.Delete(item);
            repo.UnitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
        public void DeleteFalseInput()
        {
            EmptyLists();
            departmentRepository = new DepartmentRepository(context);

            Exception ex = Assert.Throws <NullReferenceException>(() => departmentRepository.Delete(-1));

            Assert.Equal("Het afdelingId is leeg.", ex.Message);
        }
Beispiel #3
0
        public ActionResult Delete(int id, FormCollection form)
        {
            var dept = repo.GetOne(id);

            repo.Delete(dept);
            repo.UnitOfWork.Commit();

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public ActionResult DeleteDepartment(int id)
        {
            IDepartmentRepository objdep = new DepartmentRepository();

            objdep.Delete(id);

            objdep.Save();
            return(Json(new { success = true, message = "Deleted Succesfully" }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteConfirm(int id)
        {
            var dept = repo.Get單一筆部門資料(id);

            repo.Delete(dept);
            repo.UnitOfWork.Commit();

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public IHttpActionResult Delete(int Id)
        {
            var delete = departments.Delete(Id);

            if (delete > 0)
            {
                return(Ok("Department Delete Successfully"));
            }
            return(BadRequest("Failed to Delete"));
        }
Beispiel #7
0
        public IHttpActionResult Delete(int Id)
        {
            var delete = department.Delete(Id);

            if (delete > 0)
            {
                return(Ok("Department Deleted Succesfully!")); //Status 200 OK
            }
            return(BadRequest("Failed to Deleted Department"));
        }
        public async Task <IHttpActionResult> DeleteDepartment(int id)
        {
            Department department = await _repository.Delete(id);

            if (department == null)
            {
                return(NotFound());
            }
            return(Ok(department));
        }
Beispiel #9
0
        public IActionResult Delete([FromRoute] int id)
        {
            var department = _repoDepartment.Get(id);

            if (department == null)
            {
                return(NotFound());
            }
            _repoDepartment.Delete(id);
            return(NoContent());
        }
Beispiel #10
0
        public async Task <ActionResult> Delete(int id)
        {
            var dept = await _departmentRepository.GetDepartment(id);

            if (dept != null)
            {
                _departmentRepository.Delete(dept);
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #11
0
        public bool DeleteDepartment(Department department)
        {
            if (departmentRepository.IsEmpty(department))
            {
                return(departmentRepository.Delete(department.DepartmentId));
            }

            department.AddError(new Error(department.Errors.Count(), "This department is not empty, you cannot delete it.", "Business"));

            return(false);
        }
Beispiel #12
0
 public IActionResult Delete(long id)
 {
     if (ModelState.IsValid)
     {
         if (!departmentRepository.Delete(id))
         {
             return(BadRequest("Something went wrong deleting object"));
         }
     }
     return(RedirectToAction("Index"));
 }
Beispiel #13
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            dpmRepo.Save();
            if (dpmDataGridView.SelectedRows.Count == 0)
            {
                return;
            }

            dpmRepo.Delete(selectedRowDBindex());
            dpmRepo.Save();
            RefreshGui();
        }
 public bool RemoveDepartment(Department department)
 {
     try
     {
         //dataContext.Departments.Remove(department);
         //dataContext.SaveChanges();
         dataContext.Delete(department);
         return(true);
     }
     catch (Exception)
     { return(false); }
 }
Beispiel #15
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            var model = await DepartmentRepository.GetSingleAsync(id);

            if (model == null)
            {
                return(NotFound());
            }
            DepartmentRepository.Delete(model);
            await UnitOfWork.SaveChangesAsync();

            return(Ok());
        }
Beispiel #16
0
 public ActionResult Delete(int id, IFormCollection iform)
 {
     try
     {
         // TODO: Add delete logic here
         _departmentRepo.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View(nameof(Index)));
     }
 }
Beispiel #17
0
        public string Delete(int Id, string CurrentUsername)
        {
            Departments Departments = FindById(Id, CurrentUsername);

            if (Departments != null)
            {
                return(DepartmentsRepository.Delete(Id) ? null : Messages.IssueInDatabase);
            }
            else
            {
                return(Messages.NotFound);
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            try
            {
                Department department = repository.GetById(id);

                if (department == null)
                {
                    response.MessageError = new MessageError()
                    {
                        Code        = "E002",
                        Description = $"No se encontró el departamento con el id: {id}",
                    };
                    return(Request.CreateResponse(HttpStatusCode.NotFound, response));
                }

                int result = repository.Delete(id);

                if (result != zero)
                {
                    response.MessageOk = new MessageOk()
                    {
                        Code        = "C003",
                        Description = "El departamento se elimino correctamente.",
                    };
                    response.Data = department;

                    return(Request.CreateResponse(HttpStatusCode.OK, response));
                }

                response.MessageError = new MessageError()
                {
                    Code        = "E002",
                    Description = "Error al eliminar el departamento",
                };
                response.Data = department;

                return(Request.CreateResponse(HttpStatusCode.BadRequest, response));
            }
            catch (Exception ex)
            {
                response.MessageError = new MessageError()
                {
                    Code        = "E001",
                    Description = "La petición se devolvio con errores.",
                };
                response.Data = ex;

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
        //DELETE
        public IHttpActionResult Delete(int id)
        {
            // pilh id yang di delete
            var get = departmentRepository.GetDepartment(id);

            if (get == null)
            {
                return(Content(HttpStatusCode.NotFound, "Data tidak ditemukan"));
            }
            else
            {
                departmentRepository.Delete(id);
                return(Ok("Berhasil Delete"));
            }
        }
        public IActionResult Delete(int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                return(Ok(_departmentRepository.Delete(Id)));
            }
            catch
            {
                return(BadRequest(ModelState)); //or can throw new Exception
            }
        }
Beispiel #21
0
        public IHttpActionResult Delete(int id)
        {
            IHttpActionResult    result = null;
            DepartmentRepository vm     = new DepartmentRepository();

            vm.Get(id);
            if (vm.Entity.Id > 0)
            {
                vm.Delete(id);
                result = Ok(true);
            }
            else
            {
                result = NotFound();
            }
            return(result);
        }
Beispiel #22
0
 public bool DeleteDepartment(long id)
 {
     return(doInTransaction(
                () => {
         var employees = employeeRepository.FindByDepartmentIds(new List <long> {
             id
         });
         if (employees.Count != 0)
         {
             throw BusinessException.CannotDeleteDepartmentWithEmployees(
                 id,
                 employees
                 );
         }
         return departmentRepository.Delete(id) != 0;
     }
                ));
 }
Beispiel #23
0
        public bool Delete(string departmentId)
        {
            Guid deparId    = new Guid(departmentId);
            var  departemnt = DepartmentRepository.GetQueryable()
                              .FirstOrDefault(c => c.ID == deparId);

            if (departemnt != null)
            {
                Del(DepartmentRepository, departemnt.Departments);
                DepartmentRepository.Delete(departemnt);
                DepartmentRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Beispiel #24
0
        public IHttpActionResult Delete(int id)
        {
            //_repository.Delete(id);
            //return Ok("Data Berhasil di Delete");


            //var delete = _repository.delete(id);
            //if delete(!id.Equals(null)
            //{
            //    _repository.Delete(id);
            //    return Ok("Data Berhasil di Delete");
            //}
            //return BadRequest("Department Id Can't be null");
            if (!id.Equals(null))
            {
                _repository.Delete(id);
                return(Ok("Data Berhasil di Delete"));
            }
            return(BadRequest("Department Id Can't be null"));
        }
Beispiel #25
0
        public ActionResult DeleteConfirm(int id)
        {
            if (ModelState.IsValid)
            {
                var item = repoDepart.GetDepartmentByID(id);

                if (item == null)
                {
                    return(HttpNotFound());
                }

                repoDepart.Delete(item);
                repoDepart.UnitOfWork.Commit();



                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public IHttpActionResult Delete(int Id)
        {
            //var dept_id = conn.Departments.FirstOrDefault(x => x.Id == Id);
            //if (dept_id == null)
            //{
            //    return BadRequest("Failed to delete department");
            //}
            //else
            //{
            //    departments.Delete(Id);
            //    return Ok("Deleted successfully");
            //}

            var delete = departments.Delete(Id);

            if (delete > 0)
            {
                return(Ok("Department Delete Successfully"));
            }
            return(BadRequest("Failed to Delete"));
        }
        public void SaveAndDeleteTestNew()
        {
            // Save new object into DB
            // Arrange
            var department = new Department
            {
                DepartmentCode  = "XXXX",
                CreatedDateTime = DateTime.Now
            };

            // Act
            var saveResult = departmentRepository.Save(department);

            // Assert
            Assert.IsInstanceOfType(saveResult, typeof(Department));

            // Delete saved object from DB
            // Act
            departmentRepository.Delete(saveResult);

            // Assert
            Assert.IsNull(departmentRepository.FindById("XXXX"));
        }
 public bool Delete(int id)
 {
     return(_departmentRepository.Delete(id));
 }
 public bool Delete(Department department)
 {
     return(_departmentRepository.Delete(department));
 }
Beispiel #30
0
 public void DeleteForm(string keyValue)
 {
     service.Delete(t => t.Id == keyValue);
 }