Beispiel #1
0
        private CharacterSkillDTO Insert(CharacterSkillDTO characterSkill, OpenNosContext context)
        {
            CharacterSkill entity = _mapper.Map <CharacterSkill>(characterSkill);

            context.CharacterSkill.Add(entity);
            context.SaveChanges();
            return(_mapper.Map <CharacterSkillDTO>(entity));
        }
Beispiel #2
0
        private CharacterSkillDTO Update(CharacterSkill entity, CharacterSkillDTO characterSkill, OpenNosContext context)
        {
            if (entity != null)
            {
                _mapper.Map(characterSkill, entity);
                context.SaveChanges();
            }

            return(_mapper.Map <CharacterSkillDTO>(characterSkill));
        }
Beispiel #3
0
        public DeleteResult Delete(long characterId, short skillVNum)
        {
            using (var context = DataAccessHelper.CreateContext())
            {
                CharacterSkill invItem = context.CharacterSkill.FirstOrDefault(i => i.CharacterId == characterId && i.SkillVNum == skillVNum);
                if (invItem != null)
                {
                    context.CharacterSkill.Remove(invItem);
                    context.SaveChanges();
                }

                return(DeleteResult.Deleted);
            }
        }
Beispiel #4
0
        private SaveResult InsertOrUpdate(ref CharacterSkillDTO characterSkill, OpenNosContext context)
        {
            long           characterSkillId = characterSkill.CharacterSkillId;
            CharacterSkill entity           = context.CharacterSkill.FirstOrDefault(i => i.CharacterSkillId == characterSkillId);

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