Exemplo n.º 1
0
        private RespawnDTO Update(Respawn entity, RespawnDTO respawn, OpenNosContext context)
        {
            if (entity != null)
            {
                _mapper.Map(respawn, entity);
                context.SaveChanges();
            }

            return(_mapper.Map <RespawnDTO>(entity));
        }
Exemplo n.º 2
0
        private RespawnDTO Insert(RespawnDTO respawn, OpenNosContainer context)
        {
            Respawn entity = new Respawn()
            {
                CharacterId = respawn.CharacterId
            };

            context.respawn.Add(entity);
            context.SaveChanges();
            return(Mapper.Map <RespawnDTO>(entity));
        }
Exemplo n.º 3
0
        private RespawnDTO Update(Respawn entity, RespawnDTO respawn, OpenNosContainer context)
        {
            using (context)
            {
                var result = context.respawn.SingleOrDefault(c => c.RespawnId == respawn.RespawnId);
                if (result != null)
                {
                    result = Mapper.Map <RespawnDTO, Respawn>(respawn, entity);
                    context.SaveChanges();
                }
            }

            return(Mapper.Map <RespawnDTO>(entity));
        }
Exemplo n.º 4
0
 private RespawnDTO Insert(RespawnDTO respawn, OpenNosContext context)
 {
     try
     {
         Respawn entity = new Respawn()
         {
             CharacterId = respawn.CharacterId
         };
         context.Respawn.Add(entity);
         context.SaveChanges();
         return(_mapper.Map <RespawnDTO>(entity));
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
Exemplo n.º 5
0
        public SaveResult InsertOrUpdate(ref RespawnDTO respawn)
        {
            using (var context = DataAccessHelper.CreateContext())
            {
                long    characterId = respawn.CharacterId;
                short   respawnType = respawn.RespawnType;
                Respawn entity      = context.respawn.SingleOrDefault(c => c.RespawnType.Equals(respawnType) && c.CharacterId.Equals(characterId));

                if (entity == null) //new entity
                {
                    respawn = Insert(respawn, context);
                    return(SaveResult.Inserted);
                }
                else //existing entity
                {
                    respawn.RespawnId = entity.RespawnId;
                    respawn           = Update(entity, respawn, context);
                    return(SaveResult.Updated);
                }
            }
        }