private async Task <ResponseViewModel> CreateVoucher(Voucher voucher) { var response = new ResponseViewModel { Result = true, }; response.Result = voucher.VoucherId <= 0 ? await _voucherService.Insert(voucher) : await _voucherService.Update(voucher); if (response.Result == false) { response.Messages.Add($"Thao tác không thành công"); } else { response.RefObjectId = voucher.VoucherId; // send email var account = await _accountService.GetById(voucher.AccountId); voucher.Account = account; var subject = "Bạn có 1 Voucher"; var bodyHtml = await _viewRenderService.RenderToStringAsync <Voucher>("EmailTemplates/VoucherEmailTemplate", voucher); var alias = ""; await _emailService.Send(subject, bodyHtml, alias, new List <string>() { account.Email }); } return(response); }