示例#1
0
            internal static Order ToShortModel(DB.Orders dbItem, UnitOfWork unitOfWork)
            {
                var Order =
                    new Order()
                {
                    Id           = dbItem.Id,
                    Closed       = dbItem.Closed,
                    Client       = Clients.ReadShort(dbItem.Client.Id, unitOfWork),
                    Car          = Cars.ReadShort(dbItem.Car.Id, unitOfWork),
                    DateFrom     = dbItem.DateFrom,
                    DateTo       = dbItem.DateTo,
                    MileageEnd   = dbItem.MileageEnd,
                    Other        = dbItem.Other,
                    Overrun      = dbItem.Overrun,
                    Territory    = dbItem.Territory,
                    Wash         = dbItem.Wash,
                    Discount     = dbItem.Discount,
                    DiscountType = dbItem.DiscountType,
                    SiteId       = dbItem.SiteId,
                    User         = Users.Read(dbItem.User.Id, unitOfWork),
                    Deleted      = dbItem.Deleted
                };

                foreach (var od in dbItem.OrderDamagesCollection)
                {
                    Order.Damages.Add(Damages.Read(od.Damage.Id, unitOfWork));
                }

                return(Order);
            }
示例#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);
            }