deleted unused viewmodels
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.AdoptionDTO;
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.repositories.AdoptionRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class AdoptionViewModel extends ViewModel {
|
||||
private final AdoptionRepository repository;
|
||||
|
||||
@Inject
|
||||
public AdoptionViewModel(AdoptionRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all adoptions with filters.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<AdoptionDTO>>> getAllAdoptions(int page, int size, String query, String status, Long storeId, String date, Long employeeId) {
|
||||
return repository.getAllAdoptions(page, size, query, status, storeId, date, employeeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single adoption by its ID.
|
||||
*/
|
||||
public LiveData<Resource<AdoptionDTO>> getAdoptionById(Long id) {
|
||||
return repository.getAdoptionById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new adoption record.
|
||||
*/
|
||||
public LiveData<Resource<AdoptionDTO>> createAdoption(AdoptionDTO adoption) {
|
||||
return repository.createAdoption(adoption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing adoption record by ID.
|
||||
*/
|
||||
public LiveData<Resource<AdoptionDTO>> updateAdoption(Long id, AdoptionDTO adoption) {
|
||||
return repository.updateAdoption(id, adoption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an adoption record by ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteAdoption(Long id) {
|
||||
return repository.deleteAdoption(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple adoption records.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeleteAdoptions(List<String> ids) {
|
||||
return repository.bulkDeleteAdoptions(new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.AppointmentDTO;
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
import com.example.petstoremobile.repositories.AppointmentRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class AppointmentViewModel extends ViewModel {
|
||||
private final AppointmentRepository repository;
|
||||
|
||||
@Inject
|
||||
public AppointmentViewModel(AppointmentRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
// API CRUD
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all appointments with optional filters.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<AppointmentDTO>>> getAllAppointments(int page, int size, String query, String status, Long storeId, String date, Long employeeId) {
|
||||
return repository.getAllAppointments(page, size, query, status, storeId, date, employeeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple appointment records.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeleteAppointments(List<String> ids) {
|
||||
return repository.bulkDeleteAppointments(new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.ConversationDTO;
|
||||
import com.example.petstoremobile.dtos.CustomerDTO;
|
||||
import com.example.petstoremobile.dtos.MessageDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.SendMessageRequest;
|
||||
import com.example.petstoremobile.repositories.ChatRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
/**
|
||||
* ViewModel for managing chat-related UI state and data operations.
|
||||
*/
|
||||
@HiltViewModel
|
||||
public class ChatViewModel extends ViewModel {
|
||||
private final ChatRepository repository;
|
||||
|
||||
@Inject
|
||||
public ChatViewModel(ChatRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all chat conversations for the current user.
|
||||
*/
|
||||
public LiveData<Resource<List<ConversationDTO>>> getAllConversations() {
|
||||
return repository.getAllConversations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the message history for a specific conversation.
|
||||
*/
|
||||
public LiveData<Resource<List<MessageDTO>>> getMessages(Long conversationId) {
|
||||
return repository.getMessages(conversationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a plain text message to a conversation.
|
||||
*/
|
||||
public LiveData<Resource<MessageDTO>> sendMessage(Long conversationId, SendMessageRequest request) {
|
||||
return repository.sendMessage(conversationId, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of customers.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<CustomerDTO>>> getAllCustomers(int page, int size) {
|
||||
return repository.getAllCustomers(page, size);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.CustomerDTO;
|
||||
import com.example.petstoremobile.dtos.DropdownDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.repositories.CustomerRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class CustomerViewModel extends ViewModel {
|
||||
private final CustomerRepository repository;
|
||||
|
||||
@Inject
|
||||
public CustomerViewModel(CustomerRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all customers.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<CustomerDTO>>> getAllCustomers(int page, int size) {
|
||||
return repository.getAllCustomers(page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single customer by their ID.
|
||||
*/
|
||||
public LiveData<Resource<CustomerDTO>> getCustomerById(Long id) {
|
||||
return repository.getCustomerById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of customer dropdowns from the repository.
|
||||
*/
|
||||
public LiveData<Resource<List<DropdownDTO>>> getCustomerDropdowns() {
|
||||
return repository.getCustomerDropdowns();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.EmployeeDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.repositories.EmployeeRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class EmployeeViewModel extends ViewModel {
|
||||
private final EmployeeRepository employeeRepository;
|
||||
|
||||
@Inject
|
||||
public EmployeeViewModel(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
public LiveData<Resource<PageResponse<EmployeeDTO>>> getAllEmployees(int page, int size) {
|
||||
return employeeRepository.getAllEmployees(page, size);
|
||||
}
|
||||
|
||||
public LiveData<Resource<EmployeeDTO>> getEmployeeById(Long id) {
|
||||
return employeeRepository.getEmployeeById(id);
|
||||
}
|
||||
|
||||
public LiveData<Resource<EmployeeDTO>> createEmployee(EmployeeDTO dto) {
|
||||
return employeeRepository.createEmployee(dto);
|
||||
}
|
||||
|
||||
public LiveData<Resource<EmployeeDTO>> updateEmployee(Long id, EmployeeDTO dto) {
|
||||
return employeeRepository.updateEmployee(id, dto);
|
||||
}
|
||||
|
||||
public LiveData<Resource<Void>> deleteEmployee(Long id) {
|
||||
return employeeRepository.deleteEmployee(id);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.CategoryDTO;
|
||||
import com.example.petstoremobile.dtos.InventoryDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.StoreDTO;
|
||||
import com.example.petstoremobile.repositories.CategoryRepository;
|
||||
import com.example.petstoremobile.repositories.InventoryRepository;
|
||||
import com.example.petstoremobile.repositories.StoreRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class InventoryViewModel extends ViewModel {
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final CategoryRepository categoryRepository;
|
||||
private final StoreRepository storeRepository;
|
||||
|
||||
@Inject
|
||||
public InventoryViewModel(InventoryRepository inventoryRepository, CategoryRepository categoryRepository, StoreRepository storeRepository) {
|
||||
this.inventoryRepository = inventoryRepository;
|
||||
this.categoryRepository = categoryRepository;
|
||||
this.storeRepository = storeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of inventory items, with optional filtering and sorting.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<InventoryDTO>>> getAllInventory(String query, Long storeId, int page, int size, String sort) {
|
||||
return inventoryRepository.getAllInventory(query, storeId, page, size, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single inventory item by its ID.
|
||||
*/
|
||||
public LiveData<Resource<InventoryDTO>> getInventoryById(Long id) {
|
||||
return inventoryRepository.getInventoryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new inventory record.
|
||||
*/
|
||||
public LiveData<Resource<InventoryDTO>> createInventory(InventoryDTO request) {
|
||||
return inventoryRepository.createInventory(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing inventory record by ID.
|
||||
*/
|
||||
public LiveData<Resource<InventoryDTO>> updateInventory(Long id, InventoryDTO request) {
|
||||
return inventoryRepository.updateInventory(id, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an inventory record by ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteInventory(Long id) {
|
||||
return inventoryRepository.deleteInventory(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple inventory records in a single request.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeleteInventory(List<String> ids) {
|
||||
return inventoryRepository.bulkDeleteInventory(new BulkDeleteRequest(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of categories.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<CategoryDTO>>> getAllCategories(int page, int size) {
|
||||
return categoryRepository.getAllCategories(page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of stores.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<StoreDTO>>> getAllStores(int page, int size) {
|
||||
return storeRepository.getAllStores(page, size);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.DropdownDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.PetDTO;
|
||||
import com.example.petstoremobile.repositories.PetRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
import okhttp3.MultipartBody;
|
||||
|
||||
@HiltViewModel
|
||||
public class PetViewModel extends ViewModel {
|
||||
private final PetRepository repository;
|
||||
|
||||
@Inject
|
||||
public PetViewModel(PetRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of pets with filters.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<PetDTO>>> getAllPets(int page, int size, String query, String status, String species, Long storeId, Long customerId, String sort) {
|
||||
return repository.getAllPets(page, size, query, status, species, storeId, customerId, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of pets for a specific customer from the repository.
|
||||
*/
|
||||
public LiveData<Resource<List<DropdownDTO>>> getCustomerPets(Long customerId) {
|
||||
return repository.getCustomerPets(customerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of pets available for adoption from the repository.
|
||||
*/
|
||||
public LiveData<Resource<List<DropdownDTO>>> getAdoptionPets() {
|
||||
return repository.getAdoptionPets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single pet by its ID.
|
||||
*/
|
||||
public LiveData<Resource<PetDTO>> getPetById(Long id) {
|
||||
return repository.getPetById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new pet record.
|
||||
*/
|
||||
public LiveData<Resource<PetDTO>> createPet(PetDTO pet) {
|
||||
return repository.createPet(pet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing pet record by ID.
|
||||
*/
|
||||
public LiveData<Resource<PetDTO>> updatePet(Long id, PetDTO pet) {
|
||||
return repository.updatePet(id, pet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet record by ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deletePet(Long id) {
|
||||
return repository.deletePet(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple pet records.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeletePets(List<String> ids) {
|
||||
return repository.bulkDeletePets(new BulkDeleteRequest(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads an image for a specific pet.
|
||||
*/
|
||||
public LiveData<Resource<Void>> uploadPetImage(Long id, MultipartBody.Part image) {
|
||||
return repository.uploadPetImage(id, image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the image associated with a specific pet.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deletePetImage(Long id) {
|
||||
return repository.deletePetImage(id);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.ProductSupplierDTO;
|
||||
import com.example.petstoremobile.repositories.ProductSupplierRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class ProductSupplierViewModel extends ViewModel {
|
||||
private final ProductSupplierRepository repository;
|
||||
|
||||
@Inject
|
||||
public ProductSupplierViewModel(ProductSupplierRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all product-supplier relationships.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<ProductSupplierDTO>>> getAllProductSuppliers(int page, int size, String query, Long productId, Long supplierId, String sort) {
|
||||
return repository.getAllProductSuppliers(page, size, query, productId, supplierId, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new product-supplier relationship.
|
||||
*/
|
||||
public LiveData<Resource<ProductSupplierDTO>> createProductSupplier(ProductSupplierDTO dto) {
|
||||
return repository.createProductSupplier(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing product-supplier relationship.
|
||||
*/
|
||||
public LiveData<Resource<ProductSupplierDTO>> updateProductSupplier(Long productId, Long supplierId, ProductSupplierDTO dto) {
|
||||
return repository.updateProductSupplier(productId, supplierId, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a product-supplier relationship by product and supplier IDs.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteProductSupplier(Long productId, Long supplierId) {
|
||||
return repository.deleteProductSupplier(productId, supplierId);
|
||||
}
|
||||
|
||||
public LiveData<Resource<Void>> bulkDeleteProductSuppliers(List<String> ids) {
|
||||
return repository.bulkDeleteProductSuppliers(new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.CategoryDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.ProductDTO;
|
||||
import com.example.petstoremobile.repositories.CategoryRepository;
|
||||
import com.example.petstoremobile.repositories.ProductRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
import okhttp3.MultipartBody;
|
||||
|
||||
@HiltViewModel
|
||||
public class ProductViewModel extends ViewModel {
|
||||
private final ProductRepository productRepository;
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
@Inject
|
||||
public ProductViewModel(ProductRepository productRepository, CategoryRepository categoryRepository) {
|
||||
this.productRepository = productRepository;
|
||||
this.categoryRepository = categoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of products, optionally filtered by a query string, category and sorted.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<ProductDTO>>> getAllProducts(String query, Long categoryId, int page, int size, String sort) {
|
||||
return productRepository.getAllProducts(query, categoryId, page, size, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single product by its ID.
|
||||
*/
|
||||
public LiveData<Resource<ProductDTO>> getProductById(Long id) {
|
||||
return productRepository.getProductById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new product.
|
||||
*/
|
||||
public LiveData<Resource<ProductDTO>> createProduct(ProductDTO product) {
|
||||
return productRepository.createProduct(product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing product by ID.
|
||||
*/
|
||||
public LiveData<Resource<ProductDTO>> updateProduct(Long id, ProductDTO product) {
|
||||
return productRepository.updateProduct(id, product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a product by its ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteProduct(Long id) {
|
||||
return productRepository.deleteProduct(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads an image for a specific product.
|
||||
*/
|
||||
public LiveData<Resource<Void>> uploadProductImage(Long id, MultipartBody.Part image) {
|
||||
return productRepository.uploadProductImage(id, image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the image associated with a specific product.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteProductImage(Long id) {
|
||||
return productRepository.deleteProductImage(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of all product categories.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<CategoryDTO>>> getAllCategories(int page, int size) {
|
||||
return categoryRepository.getAllCategories(page, size);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.PurchaseOrderDTO;
|
||||
import com.example.petstoremobile.repositories.PurchaseOrderRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class PurchaseOrderViewModel extends ViewModel {
|
||||
private final PurchaseOrderRepository repository;
|
||||
|
||||
@Inject
|
||||
public PurchaseOrderViewModel(PurchaseOrderRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all purchase orders.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<PurchaseOrderDTO>>> getAllPurchaseOrders(int page, int size, String query, Long storeId, String sort) {
|
||||
return repository.getAllPurchaseOrders(page, size, query, storeId, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single purchase order by its ID.
|
||||
*/
|
||||
public LiveData<Resource<PurchaseOrderDTO>> getPurchaseOrderById(Long id) {
|
||||
return repository.getPurchaseOrderById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.SaleDTO;
|
||||
import com.example.petstoremobile.repositories.SaleRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class SaleViewModel extends ViewModel {
|
||||
private final SaleRepository saleRepository;
|
||||
|
||||
@Inject
|
||||
public SaleViewModel(SaleRepository saleRepository) {
|
||||
this.saleRepository = saleRepository;
|
||||
}
|
||||
|
||||
public LiveData<Resource<PageResponse<SaleDTO>>> getAllSales(int page, int size, String query, String paymentMethod, Long storeId, String sortBy) {
|
||||
return saleRepository.getAllSales(page, size, query, paymentMethod, storeId, sortBy);
|
||||
}
|
||||
|
||||
public LiveData<Resource<SaleDTO>> getSaleById(Long id) {
|
||||
return saleRepository.getSaleById(id);
|
||||
}
|
||||
|
||||
public LiveData<Resource<SaleDTO>> createSale(SaleDTO sale) {
|
||||
return saleRepository.createSale(sale);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.ServiceDTO;
|
||||
import com.example.petstoremobile.repositories.ServiceRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class ServiceViewModel extends ViewModel {
|
||||
private final ServiceRepository repository;
|
||||
|
||||
@Inject
|
||||
public ServiceViewModel(ServiceRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all services.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<ServiceDTO>>> getAllServices(int page, int size, String query, String sort) {
|
||||
return repository.getAllServices(page, size, query, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single service by its ID.
|
||||
*/
|
||||
public LiveData<Resource<ServiceDTO>> getServiceById(Long id) {
|
||||
return repository.getServiceById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new service.
|
||||
*/
|
||||
public LiveData<Resource<ServiceDTO>> createService(ServiceDTO service) {
|
||||
return repository.createService(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing service by ID.
|
||||
*/
|
||||
public LiveData<Resource<ServiceDTO>> updateService(Long id, ServiceDTO service) {
|
||||
return repository.updateService(id, service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a service by ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteService(Long id) {
|
||||
return repository.deleteService(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple services.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeleteServices(List<String> ids) {
|
||||
return repository.bulkDeleteServices(new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.DropdownDTO;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.StoreDTO;
|
||||
import com.example.petstoremobile.repositories.StoreRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class StoreViewModel extends ViewModel {
|
||||
private final StoreRepository repository;
|
||||
|
||||
@Inject
|
||||
public StoreViewModel(StoreRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all stores.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<StoreDTO>>> getAllStores(int page, int size) {
|
||||
return repository.getAllStores(page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a list of store dropdowns from the repository.
|
||||
*/
|
||||
public LiveData<Resource<List<DropdownDTO>>> getStoreDropdowns() {
|
||||
return repository.getStoreDropdowns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a list of employees for a specific store.
|
||||
*/
|
||||
public LiveData<Resource<List<DropdownDTO>>> getStoreEmployees(Long storeId) {
|
||||
return repository.getStoreEmployees(storeId);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.BulkDeleteRequest;
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.SupplierDTO;
|
||||
import com.example.petstoremobile.repositories.SupplierRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class SupplierViewModel extends ViewModel {
|
||||
private final SupplierRepository repository;
|
||||
|
||||
@Inject
|
||||
public SupplierViewModel(SupplierRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a paginated list of all suppliers.
|
||||
*/
|
||||
public LiveData<Resource<PageResponse<SupplierDTO>>> getAllSuppliers(int page, int size, String query, String sort) {
|
||||
return repository.getAllSuppliers(page, size, query, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single supplier by its ID.
|
||||
*/
|
||||
public LiveData<Resource<SupplierDTO>> getSupplierById(Long id) {
|
||||
return repository.getSupplierById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new supplier record.
|
||||
*/
|
||||
public LiveData<Resource<SupplierDTO>> createSupplier(SupplierDTO supplier) {
|
||||
return repository.createSupplier(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing supplier record by ID.
|
||||
*/
|
||||
public LiveData<Resource<SupplierDTO>> updateSupplier(Long id, SupplierDTO supplier) {
|
||||
return repository.updateSupplier(id, supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a supplier record by ID.
|
||||
*/
|
||||
public LiveData<Resource<Void>> deleteSupplier(Long id) {
|
||||
return repository.deleteSupplier(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple supplier records.
|
||||
*/
|
||||
public LiveData<Resource<Void>> bulkDeleteSuppliers(List<String> ids) {
|
||||
return repository.bulkDeleteSuppliers(new BulkDeleteRequest(ids));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.petstoremobile.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.petstoremobile.dtos.PageResponse;
|
||||
import com.example.petstoremobile.dtos.UserDTO;
|
||||
import com.example.petstoremobile.repositories.UserRepository;
|
||||
import com.example.petstoremobile.utils.Resource;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||
|
||||
@HiltViewModel
|
||||
public class UserViewModel extends ViewModel {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Inject
|
||||
public UserViewModel(UserRepository userRepository) {
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public LiveData<Resource<PageResponse<UserDTO>>> getUsers(String role, int page, int size) {
|
||||
return userRepository.getUsers(role, page, size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user