public async Task <ActionResult <CarStationConfirmation> > PostCarStation([FromBody] CarStationPostBody carStationPostBody)
        {
            var newCarStationConfirmation = await _service.CreateCarStationAsync(carStationPostBody);

            string location = _linkGenerator.GetPathByAction("GetCarStationById", "CarStation", new { carStationId = newCarStationConfirmation.Id });

            return(Created(location, newCarStationConfirmation));
        }
Example #2
0
        public async Task <CarStationConfirmation> CreateCarStationAsync(CarStationPostBody postCarStationBody)
        {
            CarStation newCarStation = new()
            {
                Id               = Guid.NewGuid(),
                CarServiceName   = postCarStationBody.CarServiceName,
                Country          = postCarStationBody.Country,
                City             = postCarStationBody.City,
                Address          = postCarStationBody.Address,
                PIB              = postCarStationBody.PIB,
                NumberOfEmplyees = 0,
                Contact          = postCarStationBody.Contact,
                Email            = postCarStationBody.Email
            };

            await _context.Set <CarStation>().AddAsync(newCarStation);

            await _context.SaveChangesAsync();

            _logger.LogInformation("CreateCarStationAsync() Executed!");
            return(await Task.FromResult(_mapper.Map <CarStationConfirmation>(newCarStation)));
        }