public async Task <ActionResult> CreateRegistration(int workshopId, [FromBody] RegistrationCreateDto registrationCreateDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Workshop workshop = await _workshopRepo.GetWorkshopById(workshopId);

            if (workshop == null)
            {
                return(NotFound(new { error = $"workshop with id {workshop} could not be found" }));
            }
            Vehicle vehicle          = _mapper.Map <Vehicle>(registrationCreateDto.Vehicle);
            int     createdVehicleId = await _vehicleRepo.CreateAsync(vehicle);

            Registration registration = _mapper.Map <Registration>(registrationCreateDto);

            registration.VehicleID      = createdVehicleId;
            registration.DateRegistered = DateTime.Now;
            User user = await _userManager.GetUserAsync(HttpContext.User);

            registration.UserID = user.Id;
            int createdRegistrationId = await _registrationRepo.CreateAsync(registration);

            return(CreatedAtAction(nameof(GetWorkshopSingleRegistration), new { workshopId = workshopId, registrationId = createdRegistrationId }, registrationCreateDto));
        }
 public async Task <StatusCodeResult> Create([FromBody] RegistrationViewModel viewModel)
 {
     if (await _service.CreateAsync(viewModel.ToModel()) == 1)
     {
         return(StatusCode((int)HttpStatusCode.OK));
     }
     else
     {
         return(StatusCode((int)HttpStatusCode.ExpectationFailed));
     }
 }