Ejemplo n.º 1
0
        protected override void ExecuteRequest(HttpContext context)
        {
            (bool isOk, User user) = CheckClaimsForUser(Request, context, _userRepository);
            if (!isOk || user == null)
            {
                return;
            }

            _questRepository.Delete(Request.QuestId).GetAwaiter().GetResult();
            context.Response.StatusCode = StatusCodes.Status200OK;
        }
Ejemplo n.º 2
0
        private string _handleQuestMessage(string[] sections)
        {
            string response = null;

            QuestDefinition entity;
            int             romId;
            QuestDefinition match;

            switch (sections[1])
            {
            case "SAVE":
                entity = new QuestDefinition(sections[2], 2);
                match  = _questRepository.GetByRomId(entity.RomId);
                if (match != null)
                {
                    match.Gold              = entity.Gold;
                    match.Level             = entity.Level;
                    match.MinLevel          = entity.MinLevel;
                    match.QuestChain        = entity.QuestChain;
                    match.RewardCategory    = entity.RewardCategory;
                    match.RewardSubCategory = entity.RewardSubCategory;
                    match.StarterId         = entity.StarterId;
                    match.EnderId           = entity.EnderId;
                    match.TP = entity.TP;
                    match.XP = entity.XP;

                    //need to loop through rewards, matching up and copying
                    //match.Rewards = entity.XP;

                    _questRepository.Update(match);
                }
                else
                {
                    _questRepository.Add(entity);
                }
                break;

            case "SAVEFROMAQB":
                entity = new QuestDefinition(sections[2], 2);
                match  = _questRepository.GetByRomId(entity.RomId);
                if (match != null)
                {
                    if ((entity.Gold > 0) && (match.Gold < 1))
                    {
                        match.Gold = entity.Gold;
                    }
                    if ((entity.Level > 0) && (match.Level < 1))
                    {
                        match.Level = entity.Level;
                    }
                    if ((entity.MinLevel > 0) && (match.MinLevel < 1))
                    {
                        match.MinLevel = entity.MinLevel;
                    }
                    if ((entity.StarterId > 0) && (match.StarterId < 1))
                    {
                        match.StarterId = entity.StarterId;
                    }
                    if ((entity.EnderId > 0) && (match.EnderId < 1))
                    {
                        match.EnderId = entity.EnderId;
                    }
                    if ((entity.TP > 0) && (match.TP < 1))
                    {
                        match.TP = entity.TP;
                    }
                    if ((entity.XP > 0) && (match.XP < 1))
                    {
                        match.XP = entity.XP;
                    }

                    //need to loop through rewards, matching up and copying
                    //match.Rewards = entity.XP;

                    _questRepository.Update(match);
                }
                else
                {
                    _questRepository.Add(entity);
                }
                break;

            case "DELETE":
                romId = Convert.ToInt32(sections[2]);
                _questRepository.Delete(romId);
                break;

            case "GET":
                romId  = Convert.ToInt32(sections[2]);
                entity = _questRepository.GetByRomId(romId);
                if (entity != null)
                {
                    response = entity.ToDelimitedString(1);
                }
                else
                {
                    response = QuestDefinition.GetNullDefinitionString(1);
                }
                break;

            case "BOOKUPDATE":
                string[] questData = sections[2].Split((char)2);
                int      i         = 0;
                romId = Convert.ToInt32(questData[i]); i++;
                string qName     = questData[i]; i++;
                int    lvl       = Convert.ToInt32(questData[i]); i++;
                int    starterId = Convert.ToInt32(questData[i]); i++;
                int    enderId   = Convert.ToInt32(questData[i]); i++;
                int    gold      = Convert.ToInt32(questData[i]); i++;
                int    xp        = Convert.ToInt32(questData[i]); i++;
                int    tp        = Convert.ToInt32(questData[i]);

                bool isUpdate = true;
                entity = _questRepository.GetByRomId(romId);
                if (entity == null)
                {
                    entity = new QuestDefinition()
                    {
                        RomId = romId, Name = qName, Level = lvl, StarterId = starterId, EnderId = enderId, Gold = gold, XP = xp, TP = tp
                    };
                    isUpdate = false;
                }
                else
                {
                    entity.Name      = qName;
                    entity.StarterId = starterId;
                    entity.EnderId   = enderId;
                    entity.Level     = lvl;
                    entity.MinLevel  = lvl - 3;
                    if (entity.MinLevel < 1)
                    {
                        entity.MinLevel = 0;
                    }
                    entity.Gold = gold;
                    entity.XP   = xp;
                    entity.TP   = tp;
                }

                if ((entity.Rewards.Count < 1) && (!string.IsNullOrEmpty(sections[3])))
                {
                    string[] rewards = sections[3].Split((char)2);

                    foreach (string rewardString in rewards)
                    {
                        if (string.IsNullOrEmpty(rewardString))
                        {
                            continue;
                        }

                        try
                        {
                            QuestReward reward = new QuestReward(rewardString, 3, _itemRepository);
                            if ((reward.RewardType != null) || (reward.Item != null))
                            {
                                entity.Rewards.Add(reward);

                                reward.Quest = entity;
                            }
                        } catch
                        {
                        }
                    }

                    //IRepository<QuestReward> rewardRep = new Repository<QuestReward>(_factory);
                    _questRepository.Update(entity);
                    //foreach (QuestReward reward in entity.Rewards)
                    //{
                    //    rewardRep.SaveOrUpdate(reward);
                    //}
                }
                break;
            }

            return(response);
        }
Ejemplo n.º 3
0
 public Quest Delete(string id)
 {
     return(_questRepository.Delete(id));
 }
Ejemplo n.º 4
0
 public void Delete(Quest quest)
 {
     _repository.Delete(Mapping.Mapped.Map <Domain.Entities.Quest>(quest));
 }
Ejemplo n.º 5
0
 public IActionResult Delete(Guid questId)
 {
     _QuestRepository.Delete(questId);
     return(Ok(ServiceResponse.Ok()));
 }