1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Contains the implementation of [`SeedDto`].

use crate::model::entity::Seed;

use super::SeedDto;

impl From<Seed> for SeedDto {
    fn from(seed: Seed) -> Self {
        Self {
            id: seed.id,
            name: seed.name,
            plant_id: seed.plant_id,
            harvest_year: seed.harvest_year,
            quantity: seed.quantity,
            use_by: seed.use_by,
            origin: seed.origin,
            taste: seed.taste,
            yield_: seed.yield_,
            generation: seed.generation,
            quality: seed.quality,
            price: seed.price,
            notes: seed.notes,
            created_by: seed.created_by,
            archived_at: seed.archived_at.map(|date| format!("{date}")),
        }
    }
}

impl From<(f32, Seed)> for SeedDto {
    fn from((_, seed): (f32, Seed)) -> Self {
        Self {
            id: seed.id,
            name: seed.name,
            plant_id: seed.plant_id,
            harvest_year: seed.harvest_year,
            quantity: seed.quantity,
            use_by: seed.use_by,
            origin: seed.origin,
            taste: seed.taste,
            yield_: seed.yield_,
            generation: seed.generation,
            quality: seed.quality,
            price: seed.price,
            notes: seed.notes,
            created_by: seed.created_by,
            archived_at: seed.archived_at.map(|date| format!("{date}")),
        }
    }
}