public async Task <IActionResult> Put([FromBody] CreateDriver command) { // TODO: Implement create driver logic await Task.CompletedTask; return(NoContent()); }
public async Task <IActionResult> Create([FromBody] CreateDriver request) { var driverId = await _manageDriverService.Create(request); // if (driverId == 0) // return BadRequest(); var driver = await _manageDriverService.GetById(driverId); return(CreatedAtAction(nameof(GetById), new { id = driverId }, driver)); }
public async Task successful_driver_registration_based_on_username_and_user_id() { // Arrange string username = "******"; // Act HttpResponseMessage userResponse = await Client.GetAsync($"users/{username}"); // Assert userResponse.StatusCode.Should().BeEquivalentTo(HttpStatusCode.OK); // Act UserDto user = await GetDeserializedPayload <UserDto>(userResponse); // Assert Assert.Equal(user.Username, username); // Arrange CreateDriver.DriverVehicle vehicle = new CreateDriver.DriverVehicle { Brand = "Audi", Model = "A1", Color = "White", SeatingCapacity = 4 }; CreateDriver request = new CreateDriver { UserId = user.Id, Vehicle = vehicle }; // Act HttpContent payload = GetSerializedPayload(request); // Send POST request with the specified payload to server; path 'drivers/'. HttpResponseMessage response = await Client.PostAsync("drivers", payload); // Assert // Verify that the HTTP Post request was successful. // (HTTP response status code 201: Created) response.StatusCode.Should().BeEquivalentTo(HttpStatusCode.Created); // Vefify that the URI of the registered user. response.Headers.Location.ToString() .Should().BeEquivalentTo($"drivers/{request.UserId}"); // Act // Fetch a user with the specified email address. DriverDto driver = await GetUserAsync(request.UserId); // Assert // Verify that the user's email address is correct. driver.UserId.Should().Equals(request.UserId); }
public async Task given_valid_driver_and_new_password_it_should_be_changed() { var user = await GetUserAsync("*****@*****.**"); var userId = user.Id; var command = new CreateDriver { UserId = userId, VehicleBrand = "Ford", VehicleName = "Fiesta", }; var payload = GetPayload(command); var response = await Client.PostAsync("drivers", payload); response.StatusCode.Should().BeEquivalentTo(HttpStatusCode.Created); }
public async Task <int> Create(CreateDriver request) { var driver = new Lst_LaiXe() { id_lg_xe = request.id_lg_xe, ten_lai_xe = request.ten_lai_xe, gioi_tinh = request.gioi_tinh, so_dien_thoai = request.so_dien_thoai, id_RFID = request.id_RFID, avatar = request.avatar, nghi_viec = request.nghi_viec, ten_donvi = request.ten_donvi, email = request.email }; _context.Lst_LaiXe.Add(driver); await _context.SaveChangesAsync(); return(driver.id_lg_xe); }
public ActionResult <CreateDriver> CreateDriver([FromBody] CreateDriver model) { try { IMapper mapper = EDeliveryProfile.CreateDriver(); var driver = mapper.Map <Driver>(model); var userIdClaim = User.FindFirst("MemberId")?.Value; var memberId = int.TryParse(userIdClaim, out var id) ? id : 0; EDeliveryDBContext dBContext = new EDeliveryDBContext(); var deliveryCompanyId = dBContext.DeliveryCompany.First(o => o.MemberId == memberId).DeliveryCompanyId; driver.DeliveryCompanyId = deliveryCompanyId; _repository.CreateDriver(driver); return(new ObjectResult(new { message = "success", statusCode = HttpStatusCode.OK, response = "Created driver" })); } catch (Exception ex) { _logger.LogError($"Failed to create new Driver:{ex}"); return(BadRequest("Failed to create new Driver")); } }
public async Task <IActionResult> Post([FromBody] CreateDriver command) { await DispatchAsync(command); return(Created($"drivers/{command.UserId}", null)); }
public async Task <IActionResult> PostAsync(CreateDriver command) { await CommandDispatcher.DispatchAsync(command); return(Created($"drivers/{command.UserId}", null)); }
public async Task <IActionResult> Post([FromBody] CreateDriver command) { await CommandDispatcher.DispatchAsync(command); return(CreatedAtAction($"driver/{command.UserId}", new Object())); }
public async Task <IActionResult> Put([FromBody] CreateDriver command) { await CommandDispather.DispathAsync(command); return(NoContent()); }
public async Task <IActionResult> Put([FromBody] CreateDriver command) { await DispatchAsync(command); return(Created($"{command.UserId}", new object())); //HTTP code 201 }
public async Task Post([FromBody] CreateDriver request) { //await _driverService.RegisterAsync(request.Email, request.Password, request.Role, request.Username); }
public async Task <IActionResult> Post([FromBody] CreateDriver command) { await DispatchAsync(command); return(NoContent()); //operacja się powiodła ale nie zwraca zagnego obiektu }