Exemplo n.º 1
0
        public void CanDeleteLocation()
        {
            var sut      = new LocationRepository(TestHelper.GetDataAccessHelper());
            var location = new LocationModel()
            {
                Name = "UnitTest Location DeleteMe"
            };
            var taskCreate = sut.CreateLocation(location);

            taskCreate.Wait();
            var createdLocation = taskCreate.Result;

            Assert.NotNull(createdLocation);
            Assert.Equal(location.Name, createdLocation.Name);
            Assert.True(createdLocation.Id > 0);

            var taskDelete = sut.DeleteLocation(createdLocation.Id);

            taskDelete.Wait();

            var taskGet = sut.GetAll();

            taskGet.Wait();
            var list = taskGet.Result;
            var item = list.SingleOrDefault(i => i.Id == createdLocation.Id);

            Assert.Null(item);
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Location location = lr.GetLocation(id);

            lr.DeleteLocation(location);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public void Test_DeleteLocation()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            repository.DeleteLocation(0);

            Assert.AreEqual(0, repository.Count());
        }
Exemplo n.º 4
0
        public void Test_DeleteLocationThanIsPartOfAFishingRecord()
        {
            LocationRepository locRepository = LocationRepository.GetInstance();

            locRepository.AddLocation(location1);

            FishingRecordRepository recRepository = FishingRecordRepository.GetInstance();

            recRepository.DeleteAllRecords();
            FishingRecord record = EntityGenerator.GetFishingRecord1();

            record.Location = location1;
            recRepository.AddRecord(record);

            locRepository.DeleteLocation(0);
        }
Exemplo n.º 5
0
 private void cmdDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Do you want to Delete?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         int RowId = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "LocId").ToString());
         if (RowId > 0)
         {
             bool res = repo.DeleteLocation(RowId);
             if (res)
             {
                 MessageBox.Show("Deleted Successfully..");
                 FillGrid();
             }
             else
             {
                 MessageBox.Show("Location already in Use. Cannot delete.");
             }
         }
     }
 }
Exemplo n.º 6
0
        public void CanCreateLocation()
        {
            var sut      = new LocationRepository(TestHelper.GetDataAccessHelper());
            var location = new LocationModel()
            {
                Name = "UnitTest Location"
            };

            var taskCreate = sut.CreateLocation(location);

            taskCreate.Wait();
            var createdLocation = taskCreate.Result;

            Assert.NotNull(createdLocation);
            Assert.Equal(location.Name, createdLocation.Name);
            Assert.True(createdLocation.Id > 0);
            // cleanup
            var taskDelete = sut.DeleteLocation(createdLocation.Id);

            taskDelete.Wait();
        }
Exemplo n.º 7
0
        public void GetMediaFileLocations_ShouldNotReturnDeletedLocations()
        {
            var LocationRepository = new LocationRepository();
            var expectedLocations  = new List <Location>();

            var fileWithLocationsId = repository.CreateMediaFile(new CreateMediaFileDto("C:/test2.jpg", MediaFileType.IMAGE_TYPE, ""));
            var fileWithLocations   = repository.GetMediaFile(fileWithLocationsId);

            var deletedLocationId = LocationRepository.CreateLocation(new CreateLocationDto("Location 1", "test", testLibrary.LibraryId, -1, -1));
            var deletedLocation   = LocationRepository.GetLocation(deletedLocationId);

            var notDeletedLocationId = LocationRepository.CreateLocation(new CreateLocationDto("Location 1", "test", testLibrary.LibraryId, -1, -1));
            var notDeletedLocation   = LocationRepository.GetLocation(notDeletedLocationId);

            repository.AddLocationToMediaFile(fileWithLocations, notDeletedLocation).ConfigureAwait(false);
            repository.AddLocationToMediaFile(fileWithLocations, deletedLocation).ConfigureAwait(false);
            LocationRepository.DeleteLocation(deletedLocation).ConfigureAwait(false);

            expectedLocations.Add(notDeletedLocation);
            var LocationsOnFileWithLocations = repository.GetMediaFileLocations(fileWithLocations);

            CollectionAssert.AreEquivalent(expectedLocations, LocationsOnFileWithLocations);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool DeleteLocation(int ID)
        {
            var locationRepository = new LocationRepository();

            return(locationRepository.DeleteLocation(ID));
        }
        public void GetLocation_ShouldReturnDeletedTag()
        {
            var tagName     = "Test name";
            var description = "Test tag";
            var locationId  = repository.CreateLocation(new CreateLocationDto(tagName, description, testLibrary.LibraryId, DatabaseConstants.DEFAULT_ID, -1));
            var location    = repository.GetLocation(locationId);

            repository.DeleteLocation(location).ConfigureAwait(false);
            Assert.AreEqual(location, repository.GetLocation(locationId));
        }
Exemplo n.º 10
0
        public void Test_DeleteLocationThanDoesntExist()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.DeleteLocation(0);
        }
Exemplo n.º 11
0
        public ActionResult DeleteItinerary(int id)
        {
            var locationToDelete = _locationRepository.DeleteLocation(id);

            return(Ok(locationToDelete));
        }
Exemplo n.º 12
0
 public async Task DeleteLocation(Location location)
 {
     await locationRepository.DeleteLocation(location);
 }
Exemplo n.º 13
0
 public ActionResult Delete(int id)
 {
     _locationRepository.DeleteLocation(id);
     TempData["Message"] = "The Location was Succesfully deleted!";
     return(RedirectToAction("Index"));
 }