public IActionResult Create([Bind] Spend spend) { if (ModelState.IsValid) { spend.UserId = GetUserId(); _spendService.Add(spend); return(RedirectToAction("Index")); } return(View(spend)); }
public ActionResult <Spend> Post([FromBody] Spend spend) { spend.UserId = GetUserId(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _spendService.Add(spend); return(CreatedAtAction("GetItem", new { id = spend.Id }, spend)); }