Exemplo n.º 1
0
        private static MinigameLogDTO insert(MinigameLogDTO account, OpenNosContext context)
        {
            MinigameLog entity = new MinigameLog();

            Mapper.Mappers.MinigameLogMapper.ToMinigameLog(account, entity);
            context.MinigameLog.Add(entity);
            context.SaveChanges();
            Mapper.Mappers.MinigameLogMapper.ToMinigameLogDTO(entity, account);
            return(account);
        }
Exemplo n.º 2
0
        private static MinigameLogDTO update(MinigameLog entity, MinigameLogDTO account, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mappers.MinigameLogMapper.ToMinigameLog(account, entity);
                context.Entry(entity).State = EntityState.Modified;
                context.SaveChanges();
            }
            if (Mapper.Mappers.MinigameLogMapper.ToMinigameLogDTO(entity, account))
            {
                return(account);
            }

            return(null);
        }
Exemplo n.º 3
0
        public static bool ToMinigameLogDTO(MinigameLog input, MinigameLogDTO output)
        {
            if (input == null)
            {
                return(false);
            }

            output.CharacterId   = input.CharacterId;
            output.EndTime       = input.EndTime;
            output.Minigame      = input.Minigame;
            output.MinigameLogId = input.MinigameLogId;
            output.Score         = input.Score;
            output.StartTime     = input.StartTime;
            return(true);
        }
Exemplo n.º 4
0
 public MinigameLogDTO LoadById(long minigameLogId)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             MinigameLog minigameLog = context.MinigameLog.FirstOrDefault(a => a.MinigameLogId.Equals(minigameLogId));
             if (minigameLog != null)
             {
                 MinigameLogDTO minigameLogDTO = new MinigameLogDTO();
                 if (Mapper.Mappers.MinigameLogMapper.ToMinigameLogDTO(minigameLog, minigameLogDTO))
                 {
                     return(minigameLogDTO);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return(null);
 }
Exemplo n.º 5
0
        public SaveResult InsertOrUpdate(ref MinigameLogDTO minigameLog)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long        minigameLogId = minigameLog.MinigameLogId;
                    MinigameLog entity        = context.MinigameLog.FirstOrDefault(c => c.MinigameLogId.Equals(minigameLogId));

                    if (entity == null)
                    {
                        minigameLog = insert(minigameLog, context);
                        return(SaveResult.Inserted);
                    }
                    minigameLog = update(entity, minigameLog, context);
                    return(SaveResult.Updated);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(SaveResult.Error);
            }
        }