Esempio n. 1
0
        public ActionResult Pick(string cardName, int draftId)
        {
            var authMember = GetAuthorizedMember();

            using (var sl = new SystemLogic())
            {
                if (!sl.IsMemberOfDraft(authMember.Id, draftId))
                {
                    return(RedirectToAction("Index"));
                }

                var draftLogic = GetDraftLogic.FromDraftId(draftId);
                var card       = sl.GetCard(cardName);

                if (card == null)
                {
                    var likeList = sl.FindCard(cardName);
                    return(Json(new { pickresult = false, reason = "Card was not found!", alternatives = likeList }));
                }

                var pickSuccess = draftLogic.PickCard(draftId, authMember.Id, card.Id);

                if (!pickSuccess)
                {
                    return(Json(new { pickresult = false, reason = "Card was already picked, try another card!" }));
                }

                DraftViewModel dvm = GetDraftViewModel(draftId);

                return(Json(new { pickresult = true, updatedDvm = dvm }));
            }
        }