public void Can_Perform_Delete_On_UserTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(Logger); var unitOfWork = provider.GetUnitOfWork(); using (var repository = CreateRepository(unitOfWork)) { var userType = MockedUserType.CreateUserType(); // Act repository.AddOrUpdate(userType); unitOfWork.Commit(); var id = userType.Id; using (var repository2 = new UserTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, SqlSyntax)) { repository2.Delete(userType); unitOfWork.Commit(); var resolved = repository2.Get(id); // Assert Assert.That(resolved, Is.Null); } } }
public int DeleteUserType(int Id) { try { _IUserTypeRepository.Delete(Id); return(_IUserTypeRepository.Save()); } catch (Exception exception) { exception.Log(); return(0); } }
public void DeleteById_WasDeleted_actualDataIsNull() { var typeIdToDelete = AddandGetTestUserType().ID; UserType actualUserType; using (var userTypeRepo = new UserTypeRepository(new brothershipEntities(ConnectionStrings.TEST_CONNECTION_STRING_NAME))) { userTypeRepo.Delete(typeIdToDelete); userTypeRepo.SaveChanges(); actualUserType = userTypeRepo.GetById(typeIdToDelete); } Assert.IsNull(actualUserType); }
void CreateView() { var listView = new ListView { ItemsSource = _db.GetUserTypes(), ItemTemplate = new DataTemplate(typeof(TextCell)) }; listView.ItemTemplate.SetBinding(TextCell.TextProperty, "Name"); listView.ItemTemplate.SetBinding(TextCell.DetailProperty, "Id"); listView.ItemTapped += async(s, e) => { var item = (UserType)e.Item; if (await DisplayAlert("削除しますか?", item.Name, "OK", "キャンセル")) { _db.Delete(item); listView.ItemsSource = _db.GetUserTypes(); } }; var entry = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White }; var addButton = new Button { Text = "Add", WidthRequest = 60, TextColor = Color.White }; addButton.Clicked += (s, e) => { if (!string.IsNullOrEmpty(entry.Text)) { var userType = new UserType { Name = entry.Text }; if (_db.SaveUserType(userType) == 0) { DisplayAlert("既に使用されています。", userType.Name, "OK"); } listView.ItemsSource = _db.GetUserTypes(); } else { DisplayAlert("必須入力", "名前を入力して下さい", "OK"); } }; var backButton = new Button { Text = "戻る", TextColor = Color.Black }; backButton.Clicked += (s, e) => { Navigation.PopModalAsync(); }; Content = new StackLayout { Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0), Children = { new StackLayout { Padding = 5, BackgroundColor = Color.Navy, Children = { entry, addButton } }, listView, backButton } }; }
public Response Delete(long CatID) { return(repo.Delete(CatID)); }