public async Task <IActionResult> OnPostAsync() { ErrorMessage = ""; if (!ModelState.IsValid) { return(Page()); } var result = await _mapAppService.Add(Map); if (!result.IsSuccess) { ErrorMessage = result.Message; return(Page()); } else { return(RedirectToPage("/Ware/Index")); } /* * try * { * var map = _mapper.Map<MapEntity>(Map); * * await _db.Maps.AddAsync(map); * * await _db.SaveChangesAsync(); * * await AddSuccess(new OperatorLog * { * Type = OperatorLogType.添加地图, * Content = JsonConvert.SerializeObject(Map) * }); * } * catch (Exception ex) * { * ErrorMessage = ex.Message; * * await AddError(new OperatorLog * { * Type = OperatorLogType.添加地图, * Content = $"Data={JsonConvert.SerializeObject(Map)},ErrorMessage={ErrorMessage}" * }); * return Page(); * } * * * * return Redirect(UrlReferer); */ }
public async Task <IActionResult> OnPostAsync() { ErrorMessage = ""; if (!ModelState.IsValid) { return(Page()); } var result = await _mapAppService.Add(Map); if (!result.IsSuccess) { ErrorMessage = result.Message; return(Page()); } else { return(RedirectToPage("/Map/Index")); } }