-
Notifications
You must be signed in to change notification settings - Fork 0
/
InMemoryCarDal.cs
86 lines (75 loc) · 2.59 KB
/
InMemoryCarDal.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
using DataAccess.Abstract;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace DataAccess.Concrete.InMemory
{
public class InMemoryCarDal : ICarDal
{
List<Car> _cars;
public InMemoryCarDal()
{
_cars = new List<Car> {
new Car { Id = 1, BrandId = 1, ColorId = 1, DailyPrice = 20, DescriptionCar = "BMW", ModelYear = 2000 },
new Car { Id = 2, BrandId = 2, ColorId = 1, DailyPrice = 30, DescriptionCar = "Audi", ModelYear = 2005 },
new Car { Id = 3, BrandId = 2, ColorId = 2, DailyPrice = 50, DescriptionCar = "Opel", ModelYear = 1980 },
new Car { Id = 4, BrandId = 1, ColorId = 2, DailyPrice = 40, DescriptionCar = "Nissan", ModelYear = 1970 }
};
}
public void Add(Car car)
{
_cars.Add(car);
}
public void Delete(Car car)
{
Car carToDelete = _cars.SingleOrDefault(c => c.Id == car.Id);
_cars.Remove(carToDelete);
}
public bool Exists(Expression<Func<Car, bool>> filter)
{
throw new NotImplementedException();
}
public Car Get(Expression<Func<Car, bool>> filter)
{
throw new NotImplementedException();
}
public List<Car> GetAll()
{
return _cars;
}
public List<Car> GetAll(Expression<Func<Car, bool>> filter = null)
{
throw new NotImplementedException();
}
public List<Car> GetById(int carId)
{
return _cars.Where(c => c.Id == carId).ToList();
}
public List<CarDetailDto2> GetCarDetailDtos(Expression<Func<Car, bool>> filter = null)
{
throw new NotImplementedException();
}
public List<CarDetailDto2> GetCarDetailDtos()
{
throw new NotImplementedException();
}
public List<CarDetailDto2> GetCarDetailDtos2(Expression<Func<Car, bool>> filter = null)
{
throw new NotImplementedException();
}
public void Update(Car car)
{
Car carToUpdate = _cars.SingleOrDefault(c => c.Id == car.Id);
carToUpdate.Id = car.Id;
carToUpdate.BrandId = car.BrandId;
carToUpdate.ColorId = car.ColorId;
carToUpdate.DailyPrice = car.DailyPrice;
carToUpdate.DescriptionCar = car.DescriptionCar;
carToUpdate.ModelYear = car.ModelYear;
}
}
}