public async Task <ActionResult <int> > RegisterFirm( [FromBody] FirmAddressDto model) { var firmaddress = new FirmAddress { AptAddress = (string)model.AptAddress, StreetAddress = (string)model.StreetAddress, City = (string)model.City, State = (string)model.State, ZipCode = (string)model.Zip, }; var addressId = await _dataAccess.CreateFirmAddressAsync(firmaddress); var firm = new Firm { Name = (string)model.Name, Type = (string)model.Type, AddressId = addressId }; var firmId = await _dataAccess.CreateFirmAsync(firm); var user = await _dataAccess.GetUserByUserNameAsync(model.UserName); var firmUser = new FirmUser { FirmId = (int)firmId, UserId = (int)user.Id, }; await _dataAccess.LinkFirmToUserAsync(firmUser); return(firmId); }
public async Task <IActionResult> CreateOrder(OrderDto orderDto) { var email = HttpContext.User.RetrieveEmailFromPrincipal(); var orderaddress = _mapper.Map <AddressDto, FirmAddress>(orderDto.ShipToAddress); var addressid = await _dataAccess.CreateFirmAddressAsync(orderaddress); var order = _mapper.Map <OrderDto, FirmOrder>(orderDto); int orderId = await _dataAccess.CreateOrderAsync(_dataRedisAccess, order, email, orderDto.DeliveryMethodId, addressid); if (orderId == 0) { return(BadRequest(new ApiResponse(400, "Problem Creating order"))); } return(Ok()); }