Пример #1
0
        public WagonEntityView GetWagonView(int id)
        {
            var wagons = _context.Wagons
                         .Where(x => x.WagonId == id)
                         .Join(_context.Trains,
                               a => a.TrainId, b => b.TrainId,
                               (a, b) => new
            {
                WagonId        = a.WagonId,
                Number         = a.Number,
                NumberOfPlaces = a.NumberOfPlaces,
                TrainNumber    = b.TrainNumber
            });

            WagonEntityView wagonViews = wagons.Select(
                x => new WagonEntityView
            {
                WagonId        = x.WagonId,
                Number         = x.Number,
                NumberOfPlaces = x.NumberOfPlaces,
                TrainNumber    = x.TrainNumber
            }).SingleOrDefault();

            if (wagonViews != null)
            {
                List <int> places = GetListOfPlacesById(GetWagonConfigId(id));
                wagonViews.Places = places;
            }

            return(wagonViews);
        }
Пример #2
0
 public static WagonView ToDomainResponse(this WagonEntityView wagon)
 {
     if (wagon != null)
     {
         return(new WagonView
         {
             WagonId = wagon.WagonId,
             Number = wagon.Number,
             NumberOfPlaces = wagon.NumberOfPlaces,
             Places = wagon.Places,
             TrainNumber = wagon.TrainNumber
         });
     }
     else
     {
         return(null);
     }
 }