Exemplo n.º 1
0
        public void CreateTrailer(TrailerViewModel trailerViewModel)
        {
            var trailer = Mapper.Map <TrailerViewModel, Trailer_M>(trailerViewModel);

            _trailerRepository.Add(trailer);
            SaveTrailer();
        }
        public Trailer CreateTrailer(string model, int maximumWeightKg, int capacity, int numberAxles, decimal height, decimal width, decimal length)
        {
            var trailer = Trailer.Create(model, maximumWeightKg, capacity, numberAxles, height, width, length);

            trailersRepository?.Add(trailer);
            persistenceContext?.SaveChanges();
            return(trailer);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <TrailerDTO> > PostActor(TrailerDTO trailerDto)
        {
            try
            {
                var mappedEntity = _mapper.Map <Trailer>(trailerDto);

                _trailerRepository.Add(mappedEntity);
                if (await _trailerRepository.Save())
                {
                    return(Created($"/api/v1.0/actors/{mappedEntity.TrailerID}", _mapper.Map <TrailerDTO>(mappedEntity)));
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }

            return(BadRequest());
        }