protected void btnDelete_Click(object sender, EventArgs e) { foreach (int rowIndex in grdPermission.SelectedRowIndexArray) { int id = Convert.ToInt32(grdPermission.DataKeys[rowIndex + grdPermission.PageIndex * grdPermission.PageSize][0]); permissionService.Delete(permissionService.FindBy(id)); } grdPermissionDataBind(); }
public void Delete_Check_CategoryPermissionForRoles_Are_Deleted() { var permissionRepository = Substitute.For <IPermissionRepository>(); var categoryPermissionForRoleRepository = Substitute.For <ICategoryPermissionForRoleRepository>(); var permissionService = new PermissionService(permissionRepository, categoryPermissionForRoleRepository); var permission = new Permission { Name = "Ghost Rider", Id = Guid.NewGuid() }; var catePermOne = new CategoryPermissionForRole { Id = Guid.NewGuid() }; var catePermTwo = new CategoryPermissionForRole { Id = Guid.NewGuid() }; var catepermrole = new List <CategoryPermissionForRole> { catePermOne, catePermTwo }; categoryPermissionForRoleRepository.GetByPermission(permission.Id).Returns(catepermrole); permissionService.Delete(permission); categoryPermissionForRoleRepository.Received().Delete(Arg.Is <CategoryPermissionForRole>(x => x.Id == catePermOne.Id)); categoryPermissionForRoleRepository.Received().Delete(Arg.Is <CategoryPermissionForRole>(x => x.Id == catePermTwo.Id)); }
public ActionResult Del1(Guid id) { var model = _permissionService.Get(id); if (model == null) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = "Quyền hạn không tồn tại", MessageType = GenericMessages.warning }; return(RedirectToAction("index")); } if (model.Lock) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = "Bạn không đủ quyền hạn để thực hiwnj thao tác này.", MessageType = GenericMessages.warning }; return(RedirectToAction("index")); } using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { _permissionService.Delete(model.Id); unitOfWork.Commit(); TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = "Xóa quyền hạn thành công", MessageType = GenericMessages.success }; return(RedirectToAction("index")); } catch (Exception ex) { LoggingService.Error(ex.Message); unitOfWork.Rollback(); TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = "Có lỗi xảy ra khi xóa quyền hạn", MessageType = GenericMessages.warning }; } } return(View(model)); }
public OptResult Delete(DelByPkViewModel vmDel) { OptResult rst = null; var token = base.ParseToken(ActionContext); rst = _perSrv.Delete(vmDel.pk); return(rst); }
public IHttpActionResult DeletePermissionById(Permission permission, string user) { if (ReferenceEquals(permission, null) || string.IsNullOrEmpty(user)) { return(BadRequest("Resources.BadRequestMessage")); } _permissionService.Delete(permission, user); return(new StatusCodeResult(HttpStatusCode.Accepted, Request)); }
public ActionResult Delete(int primaryKey) { long count = PermissionService.GetChildCount(primaryKey); if (count == 0) { int row = PermissionService.Delete(primaryKey); return(row > 0 ? Success() : Error()); } return(Error(string.Format("操作失败,请先删除该项的{0}个子级权限。", count))); }
public void Delete(PermissionDTO permission) { IWindowManager manager = new WindowManager(); DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel(); bool?showDialogResult = manager.ShowDialog(modify, null, null); if (showDialogResult != null && showDialogResult == true) { PermissionService.Delete(permission); } Reload(); }
public IHttpActionResult DeletePermissionById(Permission permission, string user) { /* * if (_permissionService.GetById(permission.PermissionId.ToString()) == null) * { * return BadRequest("The permission not exists"); * } */ _permissionService.Delete(permission, user); return(new StatusCodeResult(HttpStatusCode.Accepted, Request)); }
public void DeletePermission() { //Mock repos Mock <IRepo <Permission> > mockPermissionRepo = new Mock <IRepo <Permission> >(); //Mock unit of work Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.SetupGet(x => x.PermissionRepo).Returns(mockPermissionRepo.Object); //Permission service PermissionService permissionService = new PermissionService(mockUnitOfWork.Object); //Test permissionService.Delete(Guid.NewGuid()); }
public IHttpActionResult Delete(int id) { var result = _permissionService.Delete(id); return(Ok(result)); }