Beispiel #1
0
        public async Task <IActionResult> Get(Guid id)
        {
            using (var repository = new Repository(HttpContext.GetUserGuid()))
            {
                var cardModel = await repository.Context.Cards.FindByGuidAsync(id);

                await repository.Context.Entry(cardModel).Reference(x => x.Status).LoadAsync();

                await repository.Context.Entry(cardModel).Reference(x => x.Creator).LoadAsync();

                var cardOptions = new CardOptions();
                if (repository.ServiceUser != null)
                {
                    var isFinal = cardModel.Status.Guid == PredefinedGuids.Final;

                    cardOptions.IsEditable             = !isFinal && AuthorizeService.HashRight(repository.ServiceUser.Role, Rights.EditCard);
                    cardOptions.IsRulingEditable       = AuthorizeService.HashRight(repository.ServiceUser.Role, Rights.EditCardRuling);
                    cardOptions.IsStatusChangedAllowed = AuthorizeService.HashRight(repository.ServiceUser.Role, Rights.AllowCardStatusChange);
                }

                cardOptions.Factions        = repository.Context.Factions.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Series          = repository.Context.Series.AsNoTracking().ToList().Select(x => x.FromDal(false)).ToList();
                cardOptions.RuleSets        = repository.Context.RuleSets.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Statuses        = repository.Context.Statuses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.ArtworkLicenses = repository.Context.Licenses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.CardTypes       = repository.Context.CardTypes.Include(x => x.TemplateInfo).AsNoTracking().ToList().Select(x => x.FromDal(true)).ToList();

                cardOptions.Languages = Languages.All;

                return(Ok(cardOptions));
            }
        }
        /// <summary>
        /// This let's you know if a card is supported in a given channel.
        /// </summary>
        /// <param name="channel">Bot Connector Channel.</param>
        /// <param name="type">Card Option to be checked.</param>
        /// <returns>A bool if the card is supported in the channel.</returns>
        public static bool IsCardSupported(string channel, CardOptions type)
        {
            if (UnsupportedChannelCards.ContainsKey(channel.ToString()))
            {
                if (UnsupportedChannelCards[channel.ToString()].Contains(type))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
    private void OnValidate()
    {
        cardOptions = GetComponent <CardOptions>();
        deckOptions = GetComponent <DeckOptions>();

        if (DeckType == TypeOfDeck.Custom)
        {
        }
        else
        {
        }
    }
Beispiel #4
0
        public HttpResponseMessage Get()
        {
            var token = TokenExtracton.GetTokenFromCookie(HttpContext.Current.Request);

            using (var repository = new Repository(token))
            {
                var cardOptions = new CardOptions();
                cardOptions.Factions  = repository.Context.Factions.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Series    = repository.Context.Series.AsNoTracking().ToList().Select(x => x.FromDal(false)).ToList();
                cardOptions.RuleSets  = repository.Context.RuleSets.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Statuses  = repository.Context.Statuses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.CardTypes = repository.Context.CardTypes.Include(x => x.TemplateInfo).AsNoTracking().ToList().Select(x => x.FromDal(true)).ToList();

                return(Request.CreateResponse(cardOptions));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Get()
        {
            using (var repository = new Repository(HttpContext.GetUserGuid()))
            {
                var cardOptions = new CardOptions();
                cardOptions.Factions  = repository.Context.Factions.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Series    = repository.Context.Series.AsNoTracking().ToList().Select(x => x.FromDal(false)).ToList();
                cardOptions.RuleSets  = repository.Context.RuleSets.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Statuses  = repository.Context.Statuses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.CardTypes = repository.Context.CardTypes.Include(x => x.TemplateInfo).AsNoTracking().ToList().Select(x => x.FromDal(true)).ToList();

                cardOptions.Languages = Languages.All;


                return(Ok(cardOptions));
            }
        }
Beispiel #6
0
        public async Task <HttpResponseMessage> Get(Guid id)
        {
            var token = TokenExtracton.GetTokenFromCookie(HttpContext.Current.Request);

            using (var repository = new Repository(token))
            {
                var card = await repository.Context.Cards.FindByGuidAsync(id);

                await repository.Context.Entry(card).Reference(x => x.Status).LoadAsync();

                await repository.Context.Entry(card).Reference(x => x.Creator).LoadAsync();

                var cardOptions = new CardOptions();
                if (repository.ServiceUser != null)
                {
                    await repository.Context.Entry(repository.ServiceUser).Reference(x => x.Role).LoadAsync();

                    if (card.Status.Guid != PredefinedGuids.Final)
                    {
                        if (card.Creator.Guid == repository.ServiceUser.Guid)
                        {
                            cardOptions.IsEditable = true;
                        }
                    }
                    if (repository.ServiceUser.Role.Guid == PredefinedGuids.Developer ||
                        repository.ServiceUser.Role.Guid == PredefinedGuids.Administrator ||
                        repository.ServiceUser.Role.Guid == PredefinedGuids.ServiceUser)
                    {
                        cardOptions.IsEditable             = true;
                        cardOptions.IsStatusChangedAllowed = true;
                    }
                }

                cardOptions.Factions  = repository.Context.Factions.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Series    = repository.Context.Series.AsNoTracking().ToList().Select(x => x.FromDal(false)).ToList();
                cardOptions.RuleSets  = repository.Context.RuleSets.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Statuses  = repository.Context.Statuses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.CardTypes = repository.Context.CardTypes.Include(x => x.TemplateInfo).AsNoTracking().ToList().Select(x => x.FromDal(true)).ToList();

                return(Request.CreateResponse(cardOptions));
            }
        }
Beispiel #7
0
        public async Task <IActionResult> Get(Guid id)
        {
            using (var repository = new Repository(HttpContext.GetUserGuid()))
            {
                var card = await repository.Context.Cards.FindByGuidAsync(id);

                await repository.Context.Entry(card).Reference(x => x.Status).LoadAsync();

                await repository.Context.Entry(card).Reference(x => x.Creator).LoadAsync();

                var cardOptions = new CardOptions();
                if (repository.ServiceUser != null)
                {
                    await repository.Context.Entry(repository.ServiceUser).Reference(x => x.Role).LoadAsync();

                    if (card.Status.Guid != PredefinedGuids.Final)
                    {
                        if (card.Creator.Guid == repository.ServiceUser.Guid)
                        {
                            cardOptions.IsEditable = true;
                        }
                    }
                    if (repository.ServiceUser.Role.Guid == PredefinedGuids.Developer ||
                        repository.ServiceUser.Role.Guid == PredefinedGuids.Administrator ||
                        repository.ServiceUser.Role.Guid == PredefinedGuids.ServiceUser)
                    {
                        cardOptions.IsEditable             = true;
                        cardOptions.IsStatusChangedAllowed = true;
                    }
                }

                cardOptions.Factions  = repository.Context.Factions.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Series    = repository.Context.Series.AsNoTracking().ToList().Select(x => x.FromDal(false)).ToList();
                cardOptions.RuleSets  = repository.Context.RuleSets.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.Statuses  = repository.Context.Statuses.AsNoTracking().ToList().Select(x => x.FromDal()).ToList();
                cardOptions.CardTypes = repository.Context.CardTypes.Include(x => x.TemplateInfo).AsNoTracking().ToList().Select(x => x.FromDal(true)).ToList();

                cardOptions.Languages = Languages.All;

                return(Ok(cardOptions));
            }
        }
Beispiel #8
0
        public async Task <Result <Card> > RegisterCardAsync(CardOptions options)
        {
            if (CardExists(options.CardNumber).Result.Data == true)
            {
                return(new Result <Card>()
                {
                    Message = "Card number already exists",
                    Code = Constants.ResultCode.BadRequest
                });
            }

            if (string.IsNullOrWhiteSpace(options?.CardNumber))
            {
                return(new Result <Card>()
                {
                    Message = "Card number is empty",
                    Code = Constants.ResultCode.BadRequest
                });
            }

            if (options.CardNumber.Length != 16)
            {
                return(new Result <Card>()
                {
                    Message = "Card number requires 16 digits",
                    Code = Constants.ResultCode.BadRequest
                });
            }

            if (string.IsNullOrWhiteSpace(options.CardHolderName) ||
                string.IsNullOrWhiteSpace(options.CardHolderSurname))
            {
                return(new Result <Card>()
                {
                    Message = "Name & Surname should not be empty",
                    Code = Constants.ResultCode.BadRequest
                });
            }

            var customer = new Card()
            {
                CardNumber        = options.CardNumber,
                CardHolderName    = options.CardHolderName,
                CardHolderSurname = options.CardHolderSurname
            };

            _dbContext.Add(customer);

            try
            {
                await _dbContext.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(new Result <Card>()
                {
                    Code = Constants.ResultCode.InternalServerError,
                    Message = "Card could not be saved"
                });
            }

            return(new Result <Card>()
            {
                Code = Constants.ResultCode.Success,
                Data = customer
            });
        }
Beispiel #9
0
 private static async Task GetCardOptions()
 {
     CardOptions = await ApiClient.Get <CardOptions>();
 }