public async Task <IActionResult> PutTasksHistory(int id, TasksHistory tasksHistory)
        {
            if (id != tasksHistory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tasksHistory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TasksHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PutHabit(int id, Habit habit)
        {
            if (id != habit.Id)
            {
                return(BadRequest());
            }

            _context.Entry(habit).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HabitExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
 public async Task <int> Register(User user)
 {
     _context.Users.Add(user);
     return(await _context.SaveChangesAsync());
 }