public async Task Delete(int id) { var temp = await _db.ToDoItems.FirstOrDefaultAsync(x => x.Id == id); _db.Entry(temp).State = EntityState.Deleted; _db.SaveChanges(); }
public void Update(DtoToDoItem entity) { using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp"))) { context.ToDoList.Update(entity); context.SaveChanges(); } }
public void Delete(DtoUser entity) { using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp"))) { context.Users.Remove(entity); context.SaveChanges(); } }
public void DeleteSelectedItem(DayRepository dayRepository, ToDoTaskRepository toDoTaskRepository, ListBox listBoxDailyTasks, ToDoTaskMapper toDoTaskMapper) { using (var dbContex = new ToDoAppDbContext()) { dayRepository = new DayRepository(dbContex); toDoTaskRepository = new ToDoTaskRepository(dbContex); var itemToDelete = toDoTaskRepository.GetByName(toDoTaskMapper.Map((ToDoTaskModel)listBoxDailyTasks.SelectedItem).Name); if (itemToDelete != null) { dbContex.DailyTasks.Remove(itemToDelete); dbContex.SaveChanges(); MessageBox.Show("Task was deleted."); } else { MessageBox.Show("There is no task to delete."); } } }
public void SaveChanges() { DbContext.SaveChanges(); }