Ejemplo n.º 1
0
        public async Task <IActionResult> Put(int UserId, [FromBody] SavingGoalsModel savingTarget)
        {
            if (savingTarget.UserID != UserId)
            {
                BadRequest();
            }
            _context.Entry(savingTarget).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GoalExists(savingTarget.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <SavingGoalsModel> > Post([FromBody] SavingGoalsModel savingTarget)
        {
            _context.SavingGoals.Add(savingTarget);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSavingTargets", new SavingGoalsModel()));
        }