public async Task <IActionResult> Delete(int id) { DeleteUnitRequest request = new DeleteUnitRequest(id); DeleteUnitResponse result = await _unitAppService.deleteUnit(request); if (result.Success) { return(Ok(result)); } return(NotFound(result)); }
public void DeleteUnitNotFound() { // Fill empty string parameters "" with auto-generated string. testEntityFactory.PopulateEmptyStrings = true; UnitsFacade unitsFacade = new UnitsFacade(); int maxInt = 2147483647; DeleteUnitResponse deleteUnitResponse = unitsFacade.DeleteUnit(maxInt); Assert.AreEqual(HttpStatusCode.NotFound, deleteUnitResponse.Status); }
public Task <DeleteUnitResponse> deleteUnit(DeleteUnitRequest request) { DeleteUnitCommand command = new DeleteUnitCommand(request.Id); Task <object> unit = (Task <object>)Bus.SendCommand(command); //RabbitMQBus.Publish(command); DeleteUnitResponse response = new DeleteUnitResponse(); response = Common <DeleteUnitResponse> .checkHasNotification(_notifications, response); return(Task.FromResult(response)); }
public void DeleteUnit() { // Fill empty string parameters "" with auto-generated string. testEntityFactory.PopulateEmptyStrings = true; // Add test helpdesk. TestDataHelpdesk helpdeskData = testEntityFactory.AddHelpdesk(); // Check that helpdesk was created successfully. Assert.AreEqual(HttpStatusCode.OK, helpdeskData.Response.Status); Assert.IsTrue(helpdeskData.Response.HelpdeskID > 0); // Create a unit. ID provided is 0, which will indicates creation of new helpdesk. List <string> topics = new List <string>(new string[] { "Layouts", "Lifecycle" }); TestDataUnit unitData = testEntityFactory.AddUpdateUnit(0, helpdeskData.Response.HelpdeskID, "", "", false, topics); // Check that unit was created successfully. Assert.AreEqual(HttpStatusCode.OK, unitData.Response.Status); Assert.IsTrue(unitData.Response.UnitID > 0); // Test get, delete, get. UnitsFacade unitsFacade = new UnitsFacade(); // Get the unit that was just created. GetUnitResponse getUnitResponse = unitsFacade.GetUnit(unitData.Response.UnitID); Assert.AreEqual(HttpStatusCode.OK, getUnitResponse.Status); // Delete the unit that was just created. DeleteUnitResponse deleteUnitResponse = unitsFacade.DeleteUnit(unitData.Response.UnitID); Assert.AreEqual(HttpStatusCode.OK, deleteUnitResponse.Status); // Try getting the unit that was just deleted. Should be NotFound. //Will update unit test when get unit method is implemented that excludes units //with IsDeleted = true getUnitResponse = unitsFacade.GetUnit(unitData.Response.UnitID); Assert.IsTrue(getUnitResponse.Unit.IsDeleted); }