public ActionResult <Habit> AddNewHabit(Guid userID, [FromBody] RequestData data) { var result = Habit.NewHabit(data, userID);; if (result == null) { return(NotFound("User not found")); } return(result); }
public static Habit Create(String habit_name, String[] days, Guid user, IGainer logGainer) { if (!checkDays(days)) { return(null); } Habit habit = Habit.NewHabit(habit_name, user, logGainer); foreach (String item in days) { if ((item != "Mon") && (item != "Tue") && (item != "Wed") && (item != "Thu") && (item != "Fri") && (item != "Sat") && (item != "Sun")) { throw new Exception("Must be 3 words!"); } } foreach (String x in days) { habit.AddDaysOff(x); } habit.AddLogs(); return(habit); }