Esempio n. 1
0
 public Player(CardDomain type            = CardDomain.IronClad, int?hp = null, int?hpMax = null,
               IEnumerable <Relic> relics = null, IEnumerable <Potion> potions = null,
               int?maxEnergy = null, int?drawAmount = null)
     : base("Wilson", EntityType.Player, hp ?? 100, hpMax ?? 100)
 {
     CharacterType = type;
     if (relics != null)
     {
         foreach (var relic in relics)
         {
             relic.Player = this;
             Relics.Add(relic);
         }
     }
     if (potions != null)
     {
         //TODO check max potion slots?
         Potions = potions.ToList();
     }
     _MaxEnergy  = maxEnergy ?? 3;
     _DrawAmount = drawAmount ?? 5;
 }
Esempio n. 2
0
        public IHttpActionResult Post(DepositModel deposit)
        {
            //while (true)
            //{
            //	Card card = new Card();
            //	card.CardTypeId = 7;
            //	card.CardCompanyId = 9;
            //	card.CardHolderName = "shail";
            //	card.CardNumber = Encrypt("1212121212121212", true);
            //	card.Cvv = 200;
            //	card.ExpiryMonth = 12;
            //	card.ExpiryYear = 24;
            //	card.AccountId = 10;
            //}

            if ((deposit.DepositTypeId == 6) || (deposit.DepositTypeId == 7))
            {
                Card cartObj = new Card();
                var  encrypt = Encrypt((deposit.CardNumber).ToString(), true);
                var  card    = Uow.Repository <Card>().FirstOrDefault(c => (c.CardNumber == encrypt) && (c.Cvv == deposit.CVV));
                var  balance = BalanceDomain.GetBy(19);
                if (card != null)
                {
                    if (card.Amount >= deposit.DepositAmount)
                    {
                        Deposit depositObj = new Deposit();
                        depositObj.UserId        = 19;
                        depositObj.DepositStatus = true;
                        if (deposit.DepositTypeId == 6)
                        {
                            depositObj.DepositTypeId = 3;
                        }
                        else
                        {
                            depositObj.DepositTypeId = 4;
                        }
                        var date = DateTime.Now;
                        depositObj.DepositDate   = date;
                        depositObj.AccountId     = card.AccountId;
                        depositObj.BalanceId     = balance.BalanceId;
                        depositObj.DepositAmount = deposit.DepositAmount;
                        var depositMessage = DepositDomain.Post(depositObj);

                        if (depositMessage == "Deposit Successful!")
                        {
                            balance.BalanceAmount = balance.BalanceAmount + deposit.DepositAmount;
                            card.Amount           = card.Amount - deposit.DepositAmount;
                            BalanceDomain.Put(balance);
                            CardDomain.Put(card);
                            return(Ok("successfull"));
                        }
                        else
                        {
                            return(Ok("error"));
                        }
                    }
                    else
                    {
                        return(Ok("error"));
                    }
                }
                else
                {
                    return(Ok("error"));
                }
            }
            else if (deposit.DepositTypeId == 5)
            {
                var branch  = Uow.Repository <BankBranch>().FirstOrDefault(b => b.IFSC_Code == deposit.IFSC);
                var account = Uow.Repository <AccountDetail>().FirstOrDefault(a => (a.AccountNumber == deposit.AccountNumber) && (a.BankBranchId == branch.BankBranchId));
                if (account != null)
                {
                    if (account.AccountBalance >= deposit.DepositAmount)
                    {
                        Deposit depositObj = new Deposit();
                        var     date       = DateTime.Now;
                        depositObj.DepositDate   = date;
                        depositObj.UserId        = deposit.UserId;
                        depositObj.DepositStatus = true;
                        depositObj.DepositTypeId = deposit.DepositTypeId;
                        depositObj.AccountId     = account.AccountId;
                        var balance = BalanceDomain.GetBy(deposit.UserId);
                        depositObj.BalanceId     = balance.BalanceId;
                        depositObj.DepositAmount = deposit.DepositAmount;
                        var depositMessage = DepositDomain.Post(depositObj);

                        if (depositMessage == "Deposit Successful!")
                        {
                            account.AccountBalance = account.AccountBalance - deposit.DepositAmount;
                            AccountDetailsDomain.Put(account);
                            balance.BalanceAmount = balance.BalanceAmount + deposit.DepositAmount;
                            BalanceDomain.Put(balance);
                            return(Ok("successfull"));
                        }
                        else
                        {
                            return(Ok("error"));
                        }
                    }
                    else
                    {
                        return(Ok("error"));
                    }
                }
                else
                {
                    return(Ok("error"));
                }
            }
            else
            {
                return(Ok("error"));
            }
        }
        public IHttpActionResult Post(OrderDetailsModel orderDetail)
        {
            if (orderDetail.PaymentTypeId == 33)
            {
                var encryption = Encrypt((orderDetail.CardNumber).ToString(), true);
                var card       = Uow.Repository <Card>().FirstOrDefault(c => (c.CardNumber == encryption) && (c.Cvv == orderDetail.CVV));
                if (card != null)
                {
                    if (card.Amount >= orderDetail.Amount)
                    {
                        var cartList = Uow.Repository <Cart>().All();
                        if (cartList != null)
                        {
                            string             message;
                            int                flag            = 0;
                            List <OrderDetail> orderDetailList = new List <OrderDetail>();
                            foreach (var item in cartList)
                            {
                                if (item.UserId == orderDetail.UserId)
                                {
                                    OrderDetail detailTemp = new OrderDetail();
                                    detailTemp.ProductId = item.ProductId;
                                    detailTemp.Quantity  = item.Quantity;
                                    detailTemp.SubTotal  = item.SubTotal;
                                    var product = Uow.Repository <Product>().FirstOrDefault(p => p.ProductId == item.ProductId);
                                    detailTemp.DiscountId = product.DiscountId;
                                    detailTemp.OrderId    = orderDetail.OrderId;
                                    orderDetailList.Add(detailTemp);
                                }
                            }

                            if (orderDetailList != null)
                            {
                                try
                                {
                                    message = (OrderDetailDomain.Post(orderDetailList));
                                    if (message != "Order Placed!!")
                                    {
                                        flag = 1;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }

                            if (flag != 1)
                            {
                                var Order = Uow.Repository <Order>().FirstOrDefault(o => o.OrderId == orderDetail.OrderId);
                                Order.OrderStatus   = "true";
                                Order.PaymentTypeId = orderDetail.PaymentTypeId;
                                OrderDomain.Put(Order);
                                card.Amount = card.Amount - orderDetail.Amount;
                                CardDomain.Put(card);
                                return(Ok("items ordered"));
                            }
                            else
                            {
                                return(Ok("Order Not Placed!"));
                            }
                        }
                        else
                        {
                            return(Ok("cart is empty"));
                        }
                    }

                    else
                    {
                        return(Ok("Insufficient amount in card"));
                    }
                }
                else
                {
                    return(Ok());
                }
            }
            else if (orderDetail.PaymentTypeId == 34)
            {
                var balanceCheck = BalanceDomain.GetBy(orderDetail.UserId);
                if (balanceCheck.BalanceAmount >= orderDetail.Amount)
                {
                    balanceCheck.BalanceAmount = balanceCheck.BalanceAmount - orderDetail.Amount;
                    var message = BalanceDomain.Put(balanceCheck);
                    if (message == "Item Updated.")
                    {
                        return(Ok("items ordered"));
                    }
                    else
                    {
                        return(Ok());
                    }
                }
                else
                {
                    return(Ok("balance is not enough"));
                }
            }
            else
            {
                return(Ok("error"));
            }
        }