public static QuestHandler Create(Quest quest, User user, IQuestTypeRepository questTypeRepository) { QuestHandler questHandler = null; switch (questTypeRepository.GetAsEmum(quest.TypeId).GetAwaiter().GetResult()) { case QuestTypeAsEmum.DailySleepGoal: questHandler = new DailySleepQuestHandler(user); break; case QuestTypeAsEmum.CaloriesGoal: questHandler = new CaloriesGoalQuestHandler(); break; case QuestTypeAsEmum.DailyCaloriesLimit: questHandler = new DailyCaloriesLimitQuestHandler(); break; case QuestTypeAsEmum.DailyPhysicalActivity: questHandler = new DailyPhysicalActivityQuestHandler(); break; case QuestTypeAsEmum.WeeklyPhysicalActivity: questHandler = new WeeklyPhysicalActivityQuestHandler(); break; case QuestTypeAsEmum.Undefined: default: break; } questHandler.Quest = quest; return(questHandler); }
public static async Task <Quest> Create( AddQuestDTORequest addQuestRequest, User user, IQuestTypeRepository questTypeRepository, ICategoryRepository categoryRepository) { QuestTypeAsEmum questTypeAsEnum = await questTypeRepository.GetAsEmum(addQuestRequest.TypeId); if (questTypeAsEnum == QuestTypeAsEmum.Undefined) { return(null); } CategoryAsEnum categoryAsEnum = await categoryRepository.GetAsEnum(addQuestRequest.CategoryId); if (categoryAsEnum == CategoryAsEnum.Undefined) { return(null); } Quest quest = new Quest() { TypeId = addQuestRequest.TypeId, CategoryId = addQuestRequest.CategoryId, UserId = user.Id, XpValue = 10, CreationDate = DateTime.Now, ExpirationDate = DateTime.Now.AddDays(1) }; return(Initialize(quest, user, questTypeAsEnum, addQuestRequest)); }