public void updateCategory(CategoryDTO updatedCategory) { using (DeviceCategoryContext context = new DeviceCategoryContext()) { var category = context.Categories.FirstOrDefault(c => c.id_categ == updatedCategory.id_categ); category.categ_name = updatedCategory.categ_name; context.SaveChanges(); } }
public void deleteCategory(CategoryDTO deletedCategory) { using (DeviceCategoryContext context = new DeviceCategoryContext()) { var category = (from c in context.Categories where c.categ_name == deletedCategory.categ_name select c).First(); context.Categories.Remove(category); context.SaveChanges(); } }
public void insertUser(UserDTO insertedUser) { using (DeviceCategoryContext context = new DeviceCategoryContext()) { Users user = new Users(); user.id_user = insertedUser.id_user; user.first_name = insertedUser.first_name; user.last_name = insertedUser.last_name; user.email = insertedUser.email; user.phone_number = insertedUser.phone_number; user.login = insertedUser.login; user.password = insertedUser.password; user.id_role = insertedUser.id_role; context.Users.Add(user); context.SaveChanges(); } }
public void insertCategory(CategoryDTO insertedCategory) { using (DeviceCategoryContext context = new DeviceCategoryContext()) { Categories category = new Categories(); category.categ_name = insertedCategory.categ_name; context.Categories.Add(category); context.SaveChanges(); } }