public async Task <BaseApiResponse> AddUserGift(AddUserGiftRequest request) { request.CheckNotNull(nameof(request)); request.GiftInfo.CheckNotNull(nameof(request.GiftInfo)); request.ExpressAddressInfo.CheckNotNull(nameof(request.ExpressAddressInfo)); TryInitUserModel(); //要将新的ID 返回给前端 var userGiftId = GuidUtil.NewSequentialId(); var command = new AddUserGiftCommand( userGiftId, _user.Id, request.GiftInfo.Name, request.GiftInfo.Size, request.ExpressAddressInfo.Name, request.ExpressAddressInfo.Mobile, request.ExpressAddressInfo.Region, request.ExpressAddressInfo.Address, request.ExpressAddressInfo.Zip); var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new AddUserGiftResponse { UserGiftId = userGiftId }); }
public async Task <BaseApiResponse> AddUserGift([FromBody] AddUserGiftRequest request) { request.CheckNotNull(nameof(request)); request.GiftInfo.CheckNotNull(nameof(request.GiftInfo)); request.ExpressAddressInfo.CheckNotNull(nameof(request.ExpressAddressInfo)); var currentAccount = _contextService.GetCurrentAccount(HttpContext); //要将新的ID 返回给前端 var userGiftId = GuidUtil.NewSequentialId(); var command = new AddUserGiftCommand( userGiftId, currentAccount.UserId.ToGuid(), request.GiftInfo.Name, request.GiftInfo.Size, request.ExpressAddressInfo.Name, request.ExpressAddressInfo.Mobile, request.ExpressAddressInfo.Region, request.ExpressAddressInfo.Address, request.ExpressAddressInfo.Zip); var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new AddUserGiftResponse { UserGiftId = userGiftId }); }