public List <QuestObjectiveDTO> LoadAll()
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <QuestObjectiveDTO> result = new List <QuestObjectiveDTO>();
         foreach (QuestObjective questObjective in context.QuestObjective)
         {
             QuestObjectiveDTO dto = new QuestObjectiveDTO();
             Mapper.Mappers.QuestObjectiveMapper.ToQuestObjectiveDTO(questObjective, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
 public IEnumerable <QuestObjectiveDTO> LoadByQuestId(long questId)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <QuestObjectiveDTO> result = new List <QuestObjectiveDTO>();
         foreach (QuestObjective questObjective in context.QuestObjective.Where(s => s.QuestId == questId))
         {
             QuestObjectiveDTO dto = new QuestObjectiveDTO();
             Mapper.Mappers.QuestObjectiveMapper.ToQuestObjectiveDTO(questObjective, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Exemple #3
0
        public static bool ToQuestObjective(QuestObjectiveDTO input, QuestObjective output)
        {
            if (input == null)
            {
                return(false);
            }

            output.QuestObjectiveId = input.QuestObjectiveId;
            output.QuestId          = input.QuestId;
            output.Data             = input.Data;
            output.Objective        = input.Objective;
            output.SpecialData      = input.SpecialData;
            output.DropRate         = input.DropRate;
            output.ObjectiveIndex   = input.ObjectiveIndex;

            return(true);
        }
        public QuestObjectiveDTO Insert(QuestObjectiveDTO questObjective)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    QuestObjective entity = new QuestObjective();
                    Mapper.Mappers.QuestObjectiveMapper.ToQuestObjective(questObjective, entity);
                    context.QuestObjective.Add(entity);
                    context.SaveChanges();
                    if (Mapper.Mappers.QuestObjectiveMapper.ToQuestObjectiveDTO(entity, questObjective))
                    {
                        return(questObjective);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }