public virtual DeleteResult Delete(IEnumerable <Guid> ids)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         context.Configuration.AutoDetectChangesEnabled = false;
         foreach (Guid id in ids)
         {
             TEntity entity = context.Set <TEntity>().FirstOrDefault(i => i.Id == id);
             if (entity != null)
             {
                 context.Set <TEntity>().Remove(entity);
             }
         }
         context.SaveChanges();
         return(DeleteResult.Deleted);
     }
 }
        protected virtual TDTO Insert(TDTO dto, OpenNosContext context)
        {
            TEntity entity = MapEntity(dto);

            context.Set <TEntity>().Add(entity);
            context.SaveChanges();
            return(_mapper.Map <TDTO>(entity));
        }
        protected virtual TDTO InsertOrUpdate(OpenNosContext context, TDTO dto)
        {
            Guid    primaryKey = dto.Id;
            TEntity entity     = context.Set <TEntity>().FirstOrDefault(c => c.Id == primaryKey);

            dto = entity == null?Insert(dto, context) : Update(entity, dto, context);

            return(dto);
        }
Esempio n. 4
0
 public DeleteResult DeleteByVNum(short vNum)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         IEnumerable <ItemInstance> entity = context.ItemInstance.Where(i => i.ItemVNum == vNum);
         context.Set <ItemInstance>().RemoveRange(entity);
         context.SaveChanges();
         return(DeleteResult.Deleted);
     }
 }
Esempio n. 5
0
        protected CharacterSkillDTO InsertOrUpdate(OpenNosContext context, CharacterSkillDTO dto)
        {
            Guid           primaryKey = dto.Id;
            CharacterSkill entity     = context.Set <CharacterSkill>().FirstOrDefault(c => c.Id == primaryKey);

            if (entity == null)
            {
                return(Insert(dto, context));
            }
            else
            {
                return(Update(entity, dto, context));
            }
        }
Esempio n. 6
0
        protected CharacterSkillDTO Insert(CharacterSkillDTO dto, OpenNosContext context)
        {
            CharacterSkill entity = new CharacterSkill();

            Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkill(dto, entity);
            context.Set <CharacterSkill>().Add(entity);
            context.SaveChanges();
            if (Mapper.Mapper.Instance.CharacterSkillMapper.ToCharacterSkillDTO(entity, dto))
            {
                return(dto);
            }

            return(null);
        }
Esempio n. 7
0
        protected static QuicklistEntryDTO InsertOrUpdate(OpenNosContext context, QuicklistEntryDTO dto)
        {
            Guid           primaryKey = dto.Id;
            QuicklistEntry entity     = context.Set <QuicklistEntry>().FirstOrDefault(c => c.Id == primaryKey);

            if (entity == null)
            {
                return(Insert(dto, context));
            }
            else
            {
                return(Update(entity, dto, context));
            }
        }
Esempio n. 8
0
        protected static QuicklistEntryDTO Insert(QuicklistEntryDTO dto, OpenNosContext context)
        {
            QuicklistEntry entity = new QuicklistEntry();

            Mapper.Mappers.QuicklistEntryMapper.ToQuicklistEntry(dto, entity);
            context.Set <QuicklistEntry>().Add(entity);
            context.SaveChanges();
            if (Mapper.Mappers.QuicklistEntryMapper.ToQuicklistEntryDTO(entity, dto))
            {
                return(dto);
            }

            return(null);
        }
Esempio n. 9
0
        protected ItemInstanceDTO Insert(ItemInstanceDTO dto, OpenNosContext context)
        {
            ItemInstance entity = new ItemInstance();

            map(dto, entity);
            context.Set <ItemInstance>().Add(entity);
            context.SaveChanges();
            if (map(entity, dto))
            {
                return(dto);
            }

            return(null);
        }
Esempio n. 10
0
        protected static PartnerSkillsDTO Insert(PartnerSkillsDTO dto, OpenNosContext context)
        {
            PartnerSkills entity = new PartnerSkills();

            map(dto, entity);
            context.Set <PartnerSkills>().Add(entity);
            context.SaveChanges();
            if (map(entity, dto))
            {
                return(dto);
            }

            return(null);
        }
Esempio n. 11
0
        protected virtual TDTO InsertOrUpdate(OpenNosContext context, TDTO dto)
        {
            Guid    primaryKey = dto.Id;
            TEntity entity     = context.Set <TEntity>().FirstOrDefault(c => c.Id == primaryKey);

            if (entity == null) //new entity
            {
                dto = Insert(dto, context);
            }
            else //existing entity
            {
                dto = Update(entity, dto, context);
            }

            return(dto);
        }