Пример #1
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            ErrorMessage = "";
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = await _mapAppService.Update(id, Map);

            if (!result.IsSuccess)
            {
                ErrorMessage = result.Message;
                return(Page());
            }
            else
            {
                return(RedirectToPage("/Ware/Index"));
            }

            /*
             * try
             * {
             *  var map = await _db.Maps.FindAsync(id);
             *  if (map == null)
             *  {
             *      ErrorMessage = $"地图 {id} 不存在!";
             *      return Page();
             *  }
             *  var content = DifferenceComparison(map, Map);
             *  _mapper.Map(Map, map);
             *  await _db.SaveChangesAsync();
             *
             *
             *
             *  await AddSuccess(new OperatorLog
             *  {
             *      Type = OperatorLogType.修改地图,
             *      Content = $"Id = {id},Data = {content}"
             *  });
             * }
             * catch (Exception ex)
             * {
             *  ErrorMessage = ex.Message;
             *  await AddError(new OperatorLog
             *  {
             *      Type = OperatorLogType.修改地图,
             *      Content = $"Id = {id},Data={JsonConvert.SerializeObject(Map)},ErrorMessage={ErrorMessage}"
             *  });
             *  return Page();
             * }
             *
             * return Redirect(UrlReferer);
             */
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            ErrorMessage = "";
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = await _mapAppService.Update(id, Map);

            if (!result.IsSuccess)
            {
                ErrorMessage = result.Message;
                return(Page());
            }
            else
            {
                return(RedirectToPage("/Map/Index"));
            }
        }