Example #1
0
        public HabitResponse UpdateHabit(Guid userId, Guid habitId, HabitRequest habitRequest)
        {
            ValidateUserID(userId, habitId);
            Habit         habit        = habitRepository.GetHabitById(habitId);
            Habit         updatedHabit = HabitFactory.CreateUpdatedData(habitRequest, habit);
            List <DayOff> dayOffList   = DayOffFactory.Create(habitRequest.DaysOff, habit.ID);

            dayOffRepository.UpdateDayOff(dayOffList, habitId);
            habitRepository.UpdateHabit(habitId, updatedHabit);
            return(ConvertFromHabitToHabitResponse(updatedHabit));
        }