Esempio n. 1
0
        public ActionResult Create([FromBody] NewsDto news)
        {
            //登記操作者
            news.CreateUser = _currentUser.UserName;
            news.UpdateUser = _currentUser.UserName;

            //
            var myJson = _service.Create(news);

            return(Json(myJson));
        }
Esempio n. 2
0
        //[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() }));
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
 public async Task Post([FromBody] NewsViewModel news)
 {
     await _newsAppService.Create(news);
 }