Пример #1
0
    private static void CreateCard(int cardIndex, int cardCount)
    {
        if (cardCount == 0)
        {
            return;
        }
        PetCard target = cardLookUp[cardIndex];

        for (int i = 0; i < cardCount; i++)
        {
            PetCard newCard = Instantiate(target);
            instance.cardScroller.AddCard(newCard);
        }
    }
Пример #2
0
        public async Task AddPetCardToUserCollection(CollectInput input)
        {
            var identity = User.Claims;

            if (identity != null)
            {
                string tokenUsername = identity.FirstOrDefault(x => x.Type == "UserName").Value;
                if (tokenUsername == input.Username)
                {
                    PetCard petCard = await _petCardsService.GetPetCardById(input.PetCardID);

                    await _petCardsService.AddPetCardToUserCollection(petCard, input.Username);
                }
            }
        }
Пример #3
0
        public async Task <ActionResult <PetCard> > CreatePetCard(PetCard petcard)
        {
            var identity = User.Claims;

            if (identity != null)
            {
                string tokenUsername = identity.FirstOrDefault(x => x.Type == "UserName").Value;
                if (tokenUsername == petcard.Owner)
                {
                    await _petCardsService.CreatePetCard(petcard);

                    return(CreatedAtAction("CreatePetCard", new { id = petcard.ID }, petcard));
                }
            }
            return(null);
        }
Пример #4
0
        public async Task <ActionResult <PetCard> > GetPetCardByIdIfOwned(int petCardId)
        {
            var usernameClaim = User.Claims.FirstOrDefault(x => x.Type == "UserName");

            if (usernameClaim == null)
            {
                return(BadRequest());
            }
            string  username = usernameClaim.Value;
            PetCard petCard  = await _petCardsService.GetPetCardById(petCardId);

            if (petCard.Owner != username)
            {
                return(BadRequest());
            }
            return(Ok(petCard));
        }
Пример #5
0
        /// <summary>
        /// Updates the view.
        /// </summary>
        public void UpdateView()
        {
            //get actual scroll frame and remove from superview
            CoreGraphics.CGRect scrollViewSize = svPetListView.Frame;
            svPetListView.RemoveFromSuperview();

            //create new scroll view with old scroll view size
            svPetListView = new UIScrollView(scrollViewSize);
            uivMainView.Add(svPetListView);

            //get user pets
            List <PLFPet> userPetList = Application.PetManager.UserPets;

            //display pet cards
            int yAxisLocation = 10;

            //foreach card, dispose
            foreach (var card in petCards)
            {
                card.Dispose();
            }

            //create new list of card
            petCards = new List <PetCard>();

            //Foreach user pet
            foreach (var pet in userPetList)
            {
                //create new card
                PetCard petCard = new PetCard(pet);
                petCard.Show(svPetListView, this, new System.Drawing.Point(0, yAxisLocation));

                petCards.Add(petCard);

                yAxisLocation += 310;
            }

            svPetListView.ScrollEnabled = true;

            //set the new content size
            svPetListView.ContentSize = new CoreGraphics.CGSize(svPetListView.Bounds.Width, yAxisLocation + 20);
        }
Пример #6
0
        public async Task <IActionResult> UpdatePetCard(int ID, PetCard petCard)
        {
            var identity = User.Claims;

            if (identity != null)
            {
                string tokenUsername = identity.FirstOrDefault(x => x.Type == "UserName").Value;
                if (tokenUsername == petCard.Owner)
                {
                    if (ID != petCard.ID)
                    {
                        return(BadRequest());
                    }
                    await _petCardsService.UpdatePetCard(petCard);

                    return(NoContent());
                }
            }
            return(null);
        }
Пример #7
0
 public void AddCard(PetCard newCard)
 {
     newCard.transform.parent = transform;
 }