// Generated by Qleany v1.7.0 from entity_dtos.tera

use common::entities::UseCase;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UseCaseDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub entities: Vec<EntityId>,
    pub undoable: bool,
    pub read_only: bool,
    pub long_operation: bool,
    pub dto_in: Option<EntityId>,
    pub dto_out: Option<EntityId>,
}

impl From<UseCaseDto> for UseCase {
    fn from(dto: UseCaseDto) -> Self {
        UseCase {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            entities: dto.entities,
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            dto_in: dto.dto_in,
            dto_out: dto.dto_out,
        }
    }
}

impl From<&UseCaseDto> for UseCase {
    fn from(dto: &UseCaseDto) -> Self {
        UseCase {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            entities: dto.entities.clone(),
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            dto_in: dto.dto_in,
            dto_out: dto.dto_out,
        }
    }
}

impl From<UseCase> for UseCaseDto {
    fn from(entity: UseCase) -> Self {
        UseCaseDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            entities: entity.entities,
            undoable: entity.undoable,
            read_only: entity.read_only,
            long_operation: entity.long_operation,
            dto_in: entity.dto_in,
            dto_out: entity.dto_out,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateUseCaseDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub entities: Vec<EntityId>,
    pub undoable: bool,
    pub read_only: bool,
    pub long_operation: bool,
    pub dto_in: Option<EntityId>,
    pub dto_out: Option<EntityId>,
}

impl From<CreateUseCaseDto> for UseCase {
    fn from(dto: CreateUseCaseDto) -> Self {
        UseCase {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            entities: dto.entities,
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            dto_in: dto.dto_in,
            dto_out: dto.dto_out,
        }
    }
}

impl From<&CreateUseCaseDto> for UseCase {
    fn from(dto: &CreateUseCaseDto) -> Self {
        UseCase {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            entities: dto.entities.clone(),
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            dto_in: dto.dto_in,
            dto_out: dto.dto_out,
        }
    }
}

impl From<UseCase> for CreateUseCaseDto {
    fn from(entity: UseCase) -> Self {
        CreateUseCaseDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            entities: entity.entities,
            undoable: entity.undoable,
            read_only: entity.read_only,
            long_operation: entity.long_operation,
            dto_in: entity.dto_in,
            dto_out: entity.dto_out,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateUseCaseDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub undoable: bool,
    pub read_only: bool,
    pub long_operation: bool,
}

impl From<UpdateUseCaseDto> for UseCase {
    fn from(dto: UpdateUseCaseDto) -> Self {
        UseCase {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            entities: Default::default(),
            dto_in: Default::default(),
            dto_out: Default::default(),
        }
    }
}

impl From<&UpdateUseCaseDto> for UseCase {
    fn from(dto: &UpdateUseCaseDto) -> Self {
        UseCase {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
            entities: Default::default(),
            dto_in: Default::default(),
            dto_out: Default::default(),
        }
    }
}

impl From<UseCase> for UpdateUseCaseDto {
    fn from(entity: UseCase) -> Self {
        UpdateUseCaseDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            undoable: entity.undoable,
            read_only: entity.read_only,
            long_operation: entity.long_operation,
        }
    }
}

impl From<UseCaseDto> for UpdateUseCaseDto {
    fn from(dto: UseCaseDto) -> Self {
        UpdateUseCaseDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            undoable: dto.undoable,
            read_only: dto.read_only,
            long_operation: dto.long_operation,
        }
    }
}
pub use common::direct_access::use_case::UseCaseRelationshipField;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct UseCaseRelationshipDto {
    pub id: EntityId,
    pub field: UseCaseRelationshipField,
    pub right_ids: Vec<EntityId>,
}
