package org.example.petshopdesktop.DTOs;

import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import org.example.petshopdesktop.models.Service;

/**
 * The class for ServiceDTO, all service data stored here
 */
public class ServiceDTO {

    private SimpleIntegerProperty serviceId;
    private SimpleStringProperty serviceName;
    private SimpleStringProperty serviceDesc;
    private SimpleIntegerProperty serviceDuration;
    private SimpleDoubleProperty servicePrice;

    // constructor
    public ServiceDTO(int serviceId,
                      String serviceName,
                      String serviceDesc,
                      int serviceDuration,
                      double servicePrice) {

        this.serviceId = new SimpleIntegerProperty(serviceId);
        this.serviceName = new SimpleStringProperty(serviceName);
        this.serviceDesc = new SimpleStringProperty(serviceDesc);
        this.serviceDuration = new SimpleIntegerProperty(serviceDuration);
        this.servicePrice = new SimpleDoubleProperty(servicePrice);
    }

    // getters & setters

    public int getServiceId() {
        return serviceId.get();
    }

    public SimpleIntegerProperty serviceIdProperty() {
        return serviceId;
    }

    public void setServiceId(int serviceId) {
        this.serviceId.set(serviceId);
    }

    public String getServiceName() {
        return serviceName.get();
    }

    public SimpleStringProperty serviceNameProperty() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName.set(serviceName);
    }

    public String getServiceDesc() {
        return serviceDesc.get();
    }

    public SimpleStringProperty serviceDescProperty() {
        return serviceDesc;
    }

    public void setServiceDesc(String serviceDesc) {
        this.serviceDesc.set(serviceDesc);
    }

    public int getServiceDuration() {
        return serviceDuration.get();
    }

    public SimpleIntegerProperty serviceDurationProperty() {
        return serviceDuration;
    }

    public void setServiceDuration(int serviceDuration) {
        this.serviceDuration.set(serviceDuration);
    }

    public double getServicePrice() {
        return servicePrice.get();
    }

    public SimpleDoubleProperty servicePriceProperty() {
        return servicePrice;
    }

    public void setServicePrice(double servicePrice) {
        this.servicePrice.set(servicePrice);
    }

    /**
     * Converts DTO into Service model (for edit/delete)
     */
    public Service toService() {

        Service service = new Service(
                getServiceId(),
                getServiceName(),
                getServiceDesc(),
                getServiceDuration(),
                getServicePrice()
        );

        return service;
    }
}