public GetAddressDto Add(CreateAddressDto createAddressDto) { var address = _mapper.Map <Address>(createAddressDto); var addressInDb = _unitOfWork.AddressRepository.Add(address); _unitOfWork.SaveChanges(); return(_mapper.Map <GetAddressDto>(addressInDb)); }
public async Task <int> Create(CreateAddressDto dto, string userId) { var createdAddress = _mapper.Map <AddressDbEntity>(dto); createdAddress.CreatedBy = userId; await _dbContext.Address.AddAsync(createdAddress); await _dbContext.SaveChangesAsync(); return(createdAddress.Id); }
public async Task <IResult <Address> > ExecuteAsync(CreateAddressDto dto) { var entity = new Address { Nummer = dto.Nummer, Ort = dto.Ort, Plz = dto.Plz, Straße = dto.Straße }; await _db.AddAsync(entity); return(Result.For(entity)); }
public async Task <IActionResult> AddAddress(long customerId, [FromBody] CreateAddressDto value) { var command = new AddAddressCommand( customerId, value.Street, value.City, value.ZipCode ); var result = await messages.Dispatch(command); return(result.Match <IActionResult>( (errors) => BadRequest(errors), (address) => { var addressDto = mapper.Map <AddressDto>(address); return Ok(addressDto); })); }
public Task <IResult <Address> > ExecuteAsync(CreateAddressDto dto) { using var transaction = _unitOfWork.BeginTransaction(); return(_command.ExecuteAsync(dto).TapAsync(_ => transaction.CommitAsync())); }
public async Task <IActionResult> Create([FromBody] CreateAddressDto dto) => await GetResponse(async() => new ApiResponseViewModel(true, "Address Created Successfully", await _addressService.Create(dto, UserId)));
public static Address ToEntity(this CreateAddressDto dto) { Init(); return(Mapper.Map <Address>(dto)); }
public async Task <IActionResult> PostAsync(CreateAddressDto dto) { var result = await _useCase.ExecuteAsync(dto); return(result.ToCreatedResult()); }
public void CreateAddress(long userId, [FromBody] CreateAddressDto dto) { }
public IActionResult Create(CreateAddressDto createAddressDto) { var address = _addresService.Add(createAddressDto); return(CreatedAtAction(nameof(Get), new { id = address.Id }, address)); }