public ActionResult Create([FromBody] NewsDto news) { //登記操作者 news.CreateUser = _currentUser.UserName; news.UpdateUser = _currentUser.UserName; // var myJson = _service.Create(news); return(Json(myJson)); }
//[AbpMvcAuthorize("Administration.News")] public async Task <JsonResult> Create(NewsCreateInput model) { if (ModelState.IsValid) { await _newsAppService.Create(model); return(Json(new { result = true, errors = "" })); } model.DdlTypeItems = _newsTypeAppService.GetAll().Result .Select(p => new SelectListItem { Text = p.TypeName, Value = p.Id.ToString() }).ToList(); return(Json(new { result = false, errors = ModelState.AllModelStateErrors() })); }
public async Task <IActionResult> OnPostAsync() { try { if (ModelState.IsValid) { await _newsAppService.Create(ViewModel); return(RedirectToPage("Index")); } } catch (Exception e) { Console.WriteLine(e); throw; } return(Page()); }
public async Task Post([FromBody] NewsViewModel news) { await _newsAppService.Create(news); }