示例#1
0
        partial void BtnAddQuest(NSObject sender)
        {
            if (TxtQuestName.Text != "" && TxtEXP.Text != "" && TxtvQuestDescription.Text != "")
            {
                if (stages.Count > 0)
                {
                    if (int.TryParse(TxtEXP.Text, out int num))
                    {
                        quest = new Quest();
                        NSDateFormatter formatter = new NSDateFormatter();
                        formatter.DateFormat = "yyyy/MM/dd hh:mm:ss";
                        var fecha        = formatter.ToString(DpExpiringDate.Date);
                        var expiringDate = DateTime.ParseExact(fecha, "yyyy/MM/dd hh:mm:ss", CultureInfo.InvariantCulture);
                        if (expiringDate > DateTime.Now)
                        {
                            quest.Name         = TxtQuestName.Text;
                            quest.Description  = TxtvQuestDescription.Text;
                            quest.StartDate    = DateTime.Now;
                            quest.ExpiringDate = expiringDate;
                            quest.RewardXP     = num;
                            quest.isCompleted  = false;
                            quest.Status       = true;
                            quest.QuestStages  = stages;
                            UserPersistanceClass.myUser.ActiveQuests.Add(quest);
                            fb.AddNewQuest(quest, UserPersistanceClass.myUser.ActiveQuests.Count);
                        }
                        else
                        {
                            showMessage("Warning", "You cannot pick a past date.", this);
                        }
                    }
                    else
                    {
                        showMessage("Warning", "Experience is a numerical field, you know.", this);
                    }
                }
                else
                {
                    showMessage("Warning", "Add one stage at least.", this);
                }
            }
            else
            {
                showMessage("Warning", "you missed some fields buddy.", this);
            }


            //throw new NotImplementedException();
        }