예제 #1
0
 public IActionResult Delete(string code)
 {
     try
     {
         var entity = _service.Departments.Code(code).FirstOrDefault();
         if (entity == null)
         {
             return(NotFound(AppResult.NotFound()));
         }
         var validationData = _service.ValidateDeleteDepartment(User, entity);
         if (!validationData.IsValid)
         {
             return(BadRequest(AppResult.FailValidation(data: validationData)));
         }
         using (var trans = context.Database.BeginTransaction())
         {
             _service.DeleteDepartment(entity);
             //log event
             var ev = _sysService.GetEventForDeleteDepartment(
                 $"Admin {UserEmail} deleted department {entity.Name}", User,
                 entity);
             _sysService.CreateAppEvent(ev);
             //end log event
             context.SaveChanges();
             trans.Commit();
         }
         return(NoContent());
     }
     catch (DbUpdateException e)
     {
         _logger.Error(e);
         return(BadRequest(AppResult.FailValidation(data: new ValidationData()
                                                    .Fail(code: AppResultCode.DependencyDeleteFail))));
     }
 }
예제 #2
0
        public HttpResponseMessage DeleletComplain(int department_id)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (DepartmentService service = new DepartmentService())
                {
                    service.DeleteDepartment(department_id);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Se ha eliminado el departamento";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Eliminar departamento");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
 public IHttpActionResult DeleteTeacher([FromUri] int departmentId)
 {
     if (!_departmentService.DeleteDepartment(departmentId))
     {
         return(BadRequest($"ID #{departmentId} does not exist.  Cannot Delete"));
     }
     return(Ok("Department deleted."));
 }
        public ActionResult DeleteDepartment(Guid id, Guid clgid)
        {
            DepartmentService departmentService = new DepartmentService();;

            departmentService.DeleteDepartment(id);
            CollegeModel collegeModel = new CollegeModel();

            collegeModel.CollegeID = clgid;
            return(RedirectToAction("GetAllDepartment", "Department", collegeModel));
        }
예제 #5
0
        public override void DeleteItemCommandHandler()
        {
            var currentDept = ItemsCollectionView.CurrentItem as Department;

            if (currentDept != null)
            {
                _DepartmentService.DeleteDepartment(currentDept);
                items.Remove(currentDept);
            }
        }
예제 #6
0
        public IHttpActionResult DeleteDepartment(int ID)
        {
            var service   = new DepartmentService();
            var delDepart = service.DeleteDepartment(ID);
            var result    = new
            {
                Conut = delDepart ? "删除成功!" : "删除失败"
            };

            return(Json(result));
        }
예제 #7
0
 //Department Delete
 public ActionResult DeleteDepartment(int DepartmentID)
 {
     try
     {
         departmentService.DeleteDepartment(DepartmentID);
     }
     catch {
         return(View());
     }
     return(RedirectToAction("Index"));
 }
예제 #8
0
        public ActionResult Delete(bool confirm, long deptId, string sessionId)
        {
            if (confirm)
            {
                DepartmentService.DeleteDepartment(deptId);

                List <Department> departments = DepartmentService.GetAllDepartment();
                ViewData["departments"] = departments;
                return(RedirectToAction("All", new { sessionid = sessionId }));
            }
            return(null);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DepartmentService departmentService = new DepartmentService();

            if (departmentService.DeleteDepartment(departmentToUpdate))
            {
                MessageBox.Show("Department Deleted");
            }
            else
            {
                string msg = "";

                foreach (Error error in departmentToUpdate.Errors)
                {
                    msg += error.Description + "\n";
                }
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #10
0
        public JsonResult DeleteDepartment(int id)
        {
            var result = new ResponseModel <int>
            {
                Body = _departmentService.DeleteDepartment(id)
            };

            if (LogHelper <DepartmentRequest> .LogAction("Esmart.Permission.Application.Data.DepartmentDbAction") != null)
            {
                LogHelper <DepartmentRequest> .LogAction("Esmart.Permission.Application.Data.DepartmentDbAction")(new UpdateUserDto {
                    UserID = CurrentUser.UserId
                }, new DepartmentRequest {
                    DeparentId = id
                });

                LogHelper <DepartmentRequest> .RemoveAction("Esmart.Permission.Application.Data.DepartmentDbAction");
            }
            return(Json(result));
        }
        public async Task <JsonResult> DeleteDepartment(int id)
        {
            try
            {
                var result = await _deptService.DeleteDepartment(id);

                if (result.Status == StatusText.Successful.ToString())
                {
                    return(Json(new { datas = "", status = "Successful", message = "" }));
                }
                else
                {
                    return(Json(new { datas = "", status = "Error", message = result.StatusDetail }));
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex.Message);
                return(Json(new { datas = "", status = "Error", error = ex.Message }));
            }
        }
예제 #12
0
        public IHttpActionResult DelArr(List <int> delArr)
        {
            var  depart   = new DepartmentService();
            bool isResult = true;

            try
            {
                delArr.ForEach(item =>
                {
                    depart.DeleteDepartment(item);
                });
            }
            catch (Exception)
            {
                isResult = false;
                throw;
            }
            var result = new
            {
                Msg = isResult ? "删除成功" : "删除失败"
            };

            return(Json(result));
        }
예제 #13
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (cboDepartments.SelectedIndex != -1)
         {
             string            message = "Are you sure you wish to delete this department?";
             string            title   = "Delete";
             MessageBoxButtons buttons = MessageBoxButtons.YesNo;
             DialogResult      result  = MessageBox.Show(message, title, buttons, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 if (d.DeleteDepartment(_d.Id))
                 {
                     MessageBox.Show("Department Successfully Delete", "Delete Status",
                                     MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 Clear();
             }
             else
             {
                 Clear();
             }
         }
         else
         {
             MessageBox.Show("You must select a department to delete.", "Delete Status", MessageBoxButtons.OK
                             , MessageBoxIcon.Error);
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Delete Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #14
0
        public ActionResult Delete(Department department)
        {
            departmentService.DeleteDepartment(department.Id);

            return(RedirectToAction("Index"));
        }
예제 #15
0
 public ActionResult DeleteDepartment(int Id)
 {
     departmentService.DeleteDepartment(Id);
     return(RedirectToAction("Index"));
 }
예제 #16
0
        public ActionResult Delete(int id)
        {
            departmentService.DeleteDepartment(id);

            return(RedirectToAction("List"));
        }
예제 #17
0
 protected void delete_department_Click(object sender, EventArgs e)
 {
     DepartmentService.DeleteDepartment(department_num1.Text);
 }
예제 #18
0
        private void DeleteDepartment_ShouldInvokeRepository()
        {
            _service.DeleteDepartment(_departmentMock.Object);

            _repositoryMock.Verify(x => x.Delete(_departmentMock.Object), Times.Once);
        }