Пример #1
0
        public async Task Delete(int id)
        {
            var temp = await _db.ToDoItems.FirstOrDefaultAsync(x => x.Id == id);

            _db.Entry(temp).State = EntityState.Deleted;
            _db.SaveChanges();
        }
Пример #2
0
 public void Update(DtoToDoItem entity)
 {
     using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp")))
     {
         context.ToDoList.Update(entity);
         context.SaveChanges();
     }
 }
Пример #3
0
 public void Delete(DtoUser entity)
 {
     using (var context = new ToDoAppDbContext(_configuration.GetConnectionString("ToDoApp")))
     {
         context.Users.Remove(entity);
         context.SaveChanges();
     }
 }
Пример #4
0
 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.");
         }
     }
 }
Пример #5
0
 public void SaveChanges()
 {
     DbContext.SaveChanges();
 }