public ActionResult <Habits> Log(Guid userID, Guid id) { NpgsqlConnection _connection = new NpgsqlConnection(connString); _connection.Open(); IHabitRepository repo1 = new HabitRepository(_connection, null); try { Habit h = repo1.FindByID(id, userID); repo1.AddLog(id); Habit habit = HabitFactory.AddLog(h); _connection.Close(); return(new Habits() { ID = habit.ID, name = habit.name, user_id = habit.users, days = habit.daysoff, Log_count = habit.Logs, current_streak = habit.current_streak, longest_streak = habit.longest_streak }); } catch { return(NotFound("Failed")); } }