Esempio n. 1
0
        public IActionResult Create([Bind] Spend spend)
        {
            if (ModelState.IsValid)
            {
                spend.UserId = GetUserId();
                _spendService.Add(spend);

                return(RedirectToAction("Index"));
            }


            return(View(spend));
        }
Esempio n. 2
0
        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));
        }