-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersionServices.cs
87 lines (78 loc) · 2.02 KB
/
VersionServices.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using DataTransferObjects;
using IBL;
using IDAL;
namespace BL
{
internal class VersionServices : IVersionBL
{
private readonly IVersionDAL versionDal;
public VersionServices(IVersionDAL _versionDal)
{
versionDal = _versionDal;
}
public bool AddNew(VersionDTO version)
{
try
{
var success = versionDal.AddNew(version);
if (!success)
{
Console.WriteLine("Failed to add version in BL.");
}
return success;
}
catch (Exception ex)
{
Console.WriteLine($"Error in AddNew method: {ex.Message}");
return false;
}
}
public bool Delete(int id)
{
try
{
VersionDTO versionDto = versionDal.GetAll().Find(version => version.VersionId == id) ?? new VersionDTO();
return versionDal.Delete(versionDto);
}
catch (Exception)
{
return false;
}
}
public VersionDTO Get(int id)
{
try
{
VersionDTO versionDto = versionDal.GetAll().Find(version => version.VersionId == id) ?? new VersionDTO();
return versionDto;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
public List<VersionDTO> GetAll()
{
try
{
return versionDal.GetAll();
}
catch (Exception)
{
return new List<VersionDTO>();
}
}
public bool Update(VersionDTO version)
{
try
{
return versionDal.Update(version);
}
catch (Exception)
{
return false;
}
}
}
}