Exemple #1
0
            private static Car ToShortRentsModel(DB.Cars dbItem, UnitOfWork unitOfWork)
            {
                var car =
                    new Car()
                {
                    Id         = dbItem.Id,
                    Color      = (CarColor)dbItem.Color,
                    BodyNumber = dbItem.BodyNumber,
                    Enginge    = dbItem.Engine,
                    Kpp        = dbItem.Kpp,
                    Number     = dbItem.Number,
                    Sts        = dbItem.Sts,
                    TO         = dbItem.TO,
                    Year       = dbItem.Year,
                    Insurance  = dbItem.Insurance,
                    Model      = CarModels.Read(dbItem.Model.Id, unitOfWork),
                    Mileage    = dbItem.Mileage,
                    SiteId     = dbItem.SiteId,
                    User       = Users.Read(dbItem.User.Id, unitOfWork),
                    Deleted    = dbItem.Deleted
                };

                if (dbItem.CarRental != null)
                {
                    car.CarRental = CarRentals.Read(dbItem.CarRental.Id, unitOfWork);
                }
                foreach (var rent in dbItem.RentsCollection)
                {
                    car.Rents.Add(Rents.Read(rent.Id, unitOfWork));
                }
                return(car);
            }
Exemple #2
0
            private static Car ToModel(DB.Cars dbItem, UnitOfWork unitOfWork)
            {
                var car =
                    new Car()
                {
                    Id         = dbItem.Id,
                    Color      = (CarColor)dbItem.Color,
                    BodyType   = (Body)dbItem.Body,
                    BodyNumber = dbItem.BodyNumber,
                    Enginge    = dbItem.Engine,
                    Kpp        = dbItem.Kpp,
                    Number     = dbItem.Number,
                    Sts        = dbItem.Sts,
                    TO         = dbItem.TO,
                    Year       = dbItem.Year,
                    Insurance  = dbItem.Insurance,
                    Model      = CarModels.Read(dbItem.Model.Id, unitOfWork),
                    Mileage    = dbItem.Mileage,
                    SiteId     = dbItem.SiteId,
                    User       = Users.Read(dbItem.User.Id, unitOfWork),
                    Deleted    = dbItem.Deleted
                };

                if (dbItem.CarRental != null)
                {
                    car.CarRental = CarRentals.Read(dbItem.CarRental.Id, unitOfWork);
                }
                foreach (var damage in dbItem.DamagesCollection.Where(damage => !damage.Archive))
                {
                    car.Damages.Add(Damages.Read(damage.Id, unitOfWork));
                }
                foreach (var rent in dbItem.RentsCollection)
                {
                    car.Rents.Add(Rents.Read(rent.Id, unitOfWork));
                }
                foreach (var order in dbItem.OrdersCollection.Where(q => !q.Deleted))
                {
                    var cor = new CarOrder()
                    {
                        ClientId  = order.Client.Id,
                        DateFrom  = order.DateFrom,
                        DateTo    = order.DateTo,
                        Id        = order.Id,
                        Territory = order.Territory
                    };
                    foreach (var serv in order.OrderServicesCollection)
                    {
                        cor.Services.Add(Services.Read(serv.Service.Id, unitOfWork));
                    }
                    car.Orders.Add(cor);
                }
                return(car);
            }
            internal static Mark ToModel(DB.Marks dbItem, UnitOfWork unitOfWork)
            {
                var mark = new Mark()
                {
                    Id     = dbItem.Id,
                    Name   = dbItem.Name,
                    SiteId = dbItem.SiteId
                };

                foreach (var model in dbItem.ModelsCollection)
                {
                    mark.Models.Add(CarModels.Read(model.Id, unitOfWork));
                }
                return(mark);
            }