Exemplo n.º 1
0
        public async Task <BusDto> CreateAsync(CreateBusDto createBusDto)
        {
            using (UnitOfWork)
            {
                var bus = new Bus(
                    createBusDto.Mark,
                    createBusDto.ExpeditionNumber,
                    createBusDto.SeatCount,
                    createBusDto.Route,
                    createBusDto.CompanyId, Guid.NewGuid());

                bus.AddBusDetail(new BusDetail()
                {
                    Color          = createBusDto.Color,
                    Plate          = createBusDto.Plate,
                    Km             = createBusDto.Km,
                    ProductionDate = createBusDto.ProductionDate
                });

                await _busRepository.CreateAsync(bus);

                await UnitOfWork.SaveChangesAsync();

                return(ObjectMapper.Map <Bus, BusDto>(bus));
            }
        }