public void TasksService_Delete() { _repository.Setup(x => x.Delete(It.IsAny <Guid>())); _tasksService.Delete(Guid.NewGuid()); _repository.Verify(x => x.Delete(It.IsAny <Guid>())); }
public ActionResult Tasks_Destroy([DataSourceRequest] DataSourceRequest request, TaskViewModel task) { if (task != null) { tasksService.Delete(task); } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult <Tasky> Delete(int id) { try { return(_ts.Delete(id)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <Task> Delete(int id) { try { return(Ok(_LS.Delete(id))); } catch (System.Exception error) { return(BadRequest(error.Message)); } }
public ActionResult <string> Delete(int id) { try { _service.Delete(id); return(Ok("success")); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Delete(string id) { var task = _tasksService.Get(id); if (task == null) { return(NotFound()); } _tasksService.Delete(id); return(NoContent()); }
public async Task Delete_Should_Remove_Task_By_Id() { var taskId = 1; var expectedTasksCount = 3; var result = await _tasksService.Delete(taskId); var allTasks = await _repository.GetAllTasks(); var tasksCount = allTasks.Count; var tasksContainsRemovedTask = allTasks.Any(x => x.Id == taskId); Assert.Equal(expectedTasksCount, tasksCount); Assert.False(tasksContainsRemovedTask); }
public ActionResult Delete(int?id) { try { // TODO: Add insert logic here if (id.HasValue) { var task = tasksService.Get(id.Value); tasksService.Delete(task); } return(RedirectToAction("Index")); } catch { return(View()); } }
// DELETE api/Default1/5 public HttpResponseMessage DeleteTodo(int id) { Task todo = tasksService.Get(id); if (todo == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } try { tasksService.Delete(todo); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, todo)); }
public void DeleteTaskWithCommentsShouldDeleteTasksAndComments() { var options = new DbContextOptionsBuilder <TasksDbContext>() .UseInMemoryDatabase(databaseName: nameof(DeleteTaskWithCommentsShouldDeleteTasksAndComments)) .Options; using (var context = new TasksDbContext(options)) { var tasksService = new TasksService(context); var expected = new TaskPostDTO() { Title = "Booking1010", Description = "Verify booking commision", DateAdded = DateTime.Parse("2019-06-15T00:00:00"), Deadline = DateTime.Parse("2019-06-17T00:00:00"), TaskImportance = "High", TaskState = "Closed", DateClosed = null, Comments = new List <Comment>() { new Comment { Important = true, Text = "A nice task...", } }, }; var actual = tasksService.Create(expected, null); var afterDelete = tasksService.Delete(actual.Id); int numberOfCommentsInDb = context.Comments.CountAsync().Result; var resultExpense = context.Tasks.Find(actual.Id); Assert.IsNotNull(afterDelete); Assert.IsNull(resultExpense); Assert.AreEqual(0, numberOfCommentsInDb); } }
public async Task <IActionResult> Delete(int id) { var ret = await _tasksService.Delete(id); return(Json(ret)); }
public void Delete(int id) { _service.Delete(id); }