public async Task OnGetAsync(long?id) { if (id.HasValue) { Dto = await _service.GetByIdAsync(id.Value); if (Dto == null) { throw new KuDataNotFoundException(); } ViewData["Mode"] = "Edit"; } else { Dto = new SmsAccountDto(); ViewData["Mode"] = "Add"; } }
public async Task <IActionResult> AccountEdit(long?id) { if (id.HasValue) { //编辑 var model = await _accountService.GetByIdAsync(id.Value); if (model == null) { throw new VinoDataNotFoundException("无法取得数据!"); } ViewData["Mode"] = "Edit"; return(View(model)); } else { //新增 SmsAccountDto dto = new SmsAccountDto(); ViewData["Mode"] = "Add"; return(View(dto)); } }
public async Task <IActionResult> AccountSave(SmsAccountDto model) { await _accountService.SaveAsync(model); return(JsonData(true)); }