// // GET: /Group/Delete/5 public ActionResult Delete(int id) { IRepository <Models.Group> repo = new GroupRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); }
public bool Delete(string dn, string samName) { GroupRepository ldapGroup = new GroupRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); Group result = new Group(); credential.DN = dn; result = ldapGroup.FindBySamName(credential, samName); try { if (result != null) { return(ldapGroup.Delete(credential, result)); } else { return(false); } } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message); return(false); } }
public bool Delete(int groupId) { using (var scope = new TransactionScope()) { try { var users = _groupUser.GetAllUsers(groupId); foreach (var userId in users) { _groupUser.DeleteUser(new GroupUserIdModel() { UserId = userId, GroupId = groupId }); } var result = _group.Delete(groupId); scope.Complete(); return(result); } catch (Exception ex) { scope.Dispose(); JavaScriptSerializer js = new JavaScriptSerializer(); Log.Error("BL-Group - Delete - " + groupId, ex); throw new ReturnExceptionModel(new CustomExceptionModel() { StatusCode = HttpStatusCode.BadRequest, Message = ex.Message }); } } }
public HttpResponseMessage Delete(int id) { var repo = new GroupRepository(); var deleted = repo.Delete(id); var code = (deleted) ? HttpStatusCode.OK : HttpStatusCode.BadRequest; return(Request.CreateResponse(code, deleted)); }
public ActionResult Delete(int id) { GroupRepository groupRep = new GroupRepository(); groupRep.Delete(id); return RedirectToAction("List"); }
public ActionResult DeleteConfirmed(int id) { Group group = repGroup.Read().FirstOrDefault(x => x.ID == id); repGroup.Delete(group); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { var group = await _repository.FindById(id); await _repository.Delete(group); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { GroupRepository groupRepo = new GroupRepository(); Group group = groupRepo.GetByID(id); group.Contacts.Clear(); groupRepo.Save(group); groupRepo.Delete(group); return RedirectToAction("ListGroups",new {@parentId = AuthenticationService.LoggedUser.Id }); }
private void MenuItem_Click_Delete(object sender, RoutedEventArgs e) { MessageBoxResult res = MessageBox.Show("Действительно удалить?", "Внимание", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { _repo.Delete(SelectedGroup.Id); DataContext = this; } }
public ActionResult Delete(int id) { GroupRepository groupRepo = new GroupRepository(); Group group = groupRepo.GetByID(id); group.Contacts.Clear(); groupRepo.Save(group); groupRepo.Delete(group); return(RedirectToAction("ListGroups", new { @parentId = AuthenticationService.LoggedUser.Id })); }
public Task DeleteAsync(ApplicationGroup group) { if (group == null) { throw new ArgumentNullException("group"); } _groupRepository.Delete(group.Id); return(Task.FromResult <Object>(null)); }
public ActionResult Delete(CRUDGroupViewModel model) { GroupRepository repository = new GroupRepository(); if (model.Id.ToString() != String.Empty) { repository.Delete(model.Id); } return(RedirectToAction("Index")); }
public void Deveria_Excluir_Um_Grupo() { var group = GroupRepository.GetById(1); GroupRepository.Delete(group); Uow.Commit(); var list = GroupRepository.GetAll(); Assert.AreEqual(1, list.Count); }
public ActionResult Delete(int id, FormCollection collection) { try { IRepository <Models.Group> repo = new GroupRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); } catch { return(View()); } }
public void GroupRepository_Removed_Group_By_Entity() { //Arrange var dbContext = _fixture.DbContext; IGroupRepository repository = new GroupRepository(dbContext); var group = dbContext.Groups.FirstOrDefault(); //Act repository.Delete(group); repository.Save(); //Assert Assert.DoesNotContain(group, dbContext.Groups); }
public ActionResult Delete(GroupModel model, long?id) { var group = groupRepository.Load(id); try { groupRepository.Delete(group); return(RedirectToAction("Index")); } catch { return(HttpNotFound()); } }
public async Task Delete(GroupDTO item) { using (var repo = new GroupRepository()) { Group existing = await repo.GetById(item.Id); if (existing == null) { return; } await repo.Delete(existing); await repo.Commit(); } }
public string EditConsultant(FormDataCollection form) { var retVal = string.Empty; var operation = form.Get("oper"); var id = ConvertHelper.ToInt32(form.Get("GroupId")); if (!string.IsNullOrEmpty(operation)) { GroupInfo info; switch (operation) { case "edit": info = GroupRepository.GetInfo(id); if (info != null) { info.Name = form.Get("Name"); info.Description = form.Get("Description"); info.LeaderId = form.Get("LeaderId").ToInt32(); info.BranchId = UserContext.GetDefaultBranch(); info.EmployeeTypeId = (int)EmployeeType.Consultant; GroupRepository.Update(info); } break; case "add": info = new GroupInfo { Name = form.Get("Name"), CreatedDate = DateTime.Now, Description = form.Get("Description"), LeaderId = form.Get("LeaderId").ToInt32(), BranchId = UserContext.GetDefaultBranch(), EmployeeTypeId = (int)EmployeeType.Consultant, CreatedBy = UserContext.GetCurrentUser().UserID, }; GroupRepository.Create(info); break; case "del": GroupRepository.Delete(id); break; } StoreData.ReloadData <GroupInfo>(); } return(retVal); }
public ActionResult DeleteConfirmed(int?id) { if (id != null) { Group group = groupRepo.GetById(id.Value); if (group != null && group.UserID == AuthenticationService.LoggedUser.Id) { group.Contacts.Clear(); groupRepo.Delete(group); return(RedirectToAction("Index")); } } return(HttpNotFound()); }
public void Delete_NotThrowsException_StateIsValid() { var now = DateUtil.Now; var group = new GroupTableEntity { GroupId = Guid.NewGuid(), GroupCode = new string('Y', 20), GroupTree = new string('1', 8), Name = new string('X', 256), Description = new string('X', 1024), SortNo = int.MaxValue, Status = GroupStatus.SUSPENDED.ToString(), CreateTime = DateTimeOffset.MaxValue, UpdateTime = DateTimeOffset.MaxValue, }; var groupRepository = new GroupRepository(TestEnvironment.DBSettings); groupRepository.Create(group); Assert.IsTrue(groupRepository.Delete(group)); }
public void DeleteGroup() { GroupRepository groupRepository = new GroupRepository(new InMemoryDbContextFactory().CreateDbContext()); GroupModel groupModel = new GroupModel { Id = Guid.NewGuid(), Name = "První cenová skupina", Description = "Popisek testovací skupiny První cenová skupina" }; groupRepository.Insert(groupModel); var groupRepositoryResponse = groupRepository.GetById(groupModel.Id); Assert.NotNull(groupRepositoryResponse); GroupRepository groupRepository2 = new GroupRepository(new InMemoryDbContextFactory().CreateDbContext()); groupRepository2.Delete(groupModel); var groupRepositoryResponse2 = groupRepository2.GetById(groupModel.Id); Assert.Null(groupRepositoryResponse2); }
public ActionResult DeleteGroup(int id) { if (blgroup.Delete(id)) { ViewData["id"] = "Group_ParentId"; ViewData["name"] = "Group.ParentId"; return(Json(new JsonData() { Script = JavaScript("alert('حذف شد');").Script, Success = true, Html = this.RenderPartialToString("_GroupList", blgroup.Select().ToList()) })); } else { return(Json(new JsonData { Script = JavaScript("alert('حذف نشد');").Script, Success = false, Html = "" })); } }
public ActionResult DeleteGroup(int id) { if (blGroup.Delete(id)) { ViewData["id"] = "Group_ParentId"; ViewData["name"] = "Group.ParentId"; return(Json(new JsonData() { Script = MessageBox.Show("با موفقیت حذف شد", MessageType.Success).Script, Success = true, Html = this.RenderPartialToString("_GroupList", blGroup.Select().ToList()) })); } else { return(Json(new JsonData { Script = MessageBox.Show("حذف نشد", MessageType.Error).Script, Success = false, Html = "" })); } }
private void DeleteGroup(object sender, EventArgs e) { MessageBoxResult result = MessageBox.Show("Czy na pewno chcesz usunąć tę grupę? Zmiany będą nieodwracalne.", "Usuwanie grupy", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { List <Account> accountList = groupRepository.GetUsersFromGroup(actualGroup.GroupID); Role role = accountRepository.GetRole("User"); foreach (Account account in accountList) { Account editAccount = accountRepository.Get(account.AccountID); if (!editAccount.Role.Name.Equals("User")) { editAccount.RoleID = role.RoleID; editAccount.Role = role; accountRepository.Edit(editAccount); } } groupRepository.Delete(actualGroup.GroupID); MessageBox.Show("Konto zostało usunięte.", "Usuwanie konta zakończone", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } }
public void Delete(Group group) { _repository.Delete(group); }
public OptResult DeleteBatch(IEnumerable <string> ids) { OptResult rst = null; //1、组织是否存在 var predicate1 = Predicates.Field <Group>(gp => gp.gp_id, Operator.Eq, ids); var count = _groupRep.Count(predicate1); if (count < ids.Count()) { rst = OptResult.Build(ResultCode.DataNotFound, Msg_BatchDeleteGroup); return(rst); } //2、系统预制不允许删除 PredicateGroup pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pg.Predicates.Add(predicate1); var predicate2 = Predicates.Field <Group>(gp => gp.gp_system, Operator.Eq, true); pg.Predicates.Add(predicate2); count = _groupRep.Count(pg); if (count > 0) { rst = OptResult.Build(ResultCode.DataSystem, Msg_BatchDeleteGroup + "失败"); return(rst); } //3、admin不允许删除 pg.Predicates.Remove(predicate2); predicate2 = Predicates.Field <Group>(gp => gp.gp_code, Operator.Eq, "admin"); pg.Predicates.Add(predicate2); count = _groupRep.Count(pg); if (count > 0) { rst = OptResult.Build(ResultCode.DataAddmin, Msg_BatchDeleteGroup + "失败"); return(rst); } //3、是否包含下级组织 var hasChild = HasChild(ids); if (hasChild) { rst = OptResult.Build(ResultCode.DataInUse, string.Format("{0},存在下级组织", Msg_BatchDeleteGroup)); return(rst); } //4、是否已被分配 var assigned = HasUser(ids); if (assigned) { rst = OptResult.Build(ResultCode.DataInUse, string.Format("{0},已分配到用户", Msg_BatchDeleteGroup)); return(rst); } //删除 try { bool val = _groupRep.Delete(predicate1); rst = OptResult.Build(val ? ResultCode.Success : ResultCode.Fail, Msg_BatchDeleteGroup); } catch (Exception ex) { LogHelper.LogError(Msg_BatchDeleteGroup, ex); rst = OptResult.Build(ResultCode.DbError, Msg_BatchDeleteGroup); } return(rst); }
public ActionResult DeleteConfirmed(int id) { _groupRepo.Delete(id); return(RedirectToAction("Index")); }
public void DeleteGroup(int groupId) { var localGroup = GetGroupById(groupId); groupRepo.Delete(localGroup); }
public void DeleteById(int id) { repository.Delete(id); }
public void DeleteGroup(GroupDTO group, string currentUser) { _groupRepo.Delete(_groupRepo.GetGroupById(group.Id).First(), currentUser); }
public bool Delete(int id) { return(_groupRepository.Delete(id)); }
public void Delete() => repository.Delete(model);
public ActionResult DeleteGroup(int id) { var rep = new GroupRepository(); rep.Delete(id); return RedirectToAction("Group"); }