public IActionResult Create([FromBody] Todo todo) { if (todo.Title == null || todo.Body == null) { return(BadRequest()); } todo.PersonId = helper.GetPersonId(User); todo = repo.Create(todo); return(new ObjectResult(todo)); }
public IActionResult Create([FromBody] Todo todo) { if (todo.Title == null || todo.Body == null) { return(BadRequest()); } todo.PersonId = UserHelper.GetPersonId(User); todo = repo.Create(todo); // null personId as we don't want it in resp todo.PersonId = null; return(new OkObjectResult(todo)); }
public ActionResult Create(Todo item) { if (!ModelState.IsValid) { return(View(item)); } try { //item.ApplicationUserId = User.Identity.GetUserId(); _db.Create(item); return(View("List", _db.getAll().Where(x => x.ApplicationUserId == User.Identity.GetUserId()).ToList())); } catch (Exception ex) { ModelState.AddModelError("", "işlem yapılırken bir hata oluştu - Hata:" + ex.Message); return(View(item)); } }