public ActionResult <Habits> AddNewHabit(Guid userID, [FromBody] RequestData data) { NpgsqlConnection _connection = new NpgsqlConnection(connString); _connection.Open(); IHabitRepository repo1 = new HabitRepository(_connection, null); IGainer logGainer = new LogSuccess(); try { Habit h = HabitFactory.Create(data.Name, data.days, userID, logGainer); repo1.CreateHabit(h, data.days); repo1.AddLog(h.ID); repo1.AddStreak(h.ID, h.getStreak()); return(new Habits() { ID = h.ID, name = h.name, user_id = h.users, Log_count = h.Logs, days = h.daysoff, current_streak = h.current_streak, longest_streak = h.longest_streak }); } catch { return(NotFound("user not found")); } }