List <CardHistory> IHistoryDAO.GetCardHistory(String CardToSearchFor)
        {
            using (var GiftEntity = new GiftEntities())
            {
                List <CardHistory> Histories = new List <CardHistory>();
                ICardRepository    CardData  = new CardRepository(GiftEntity);
                Card WhichCard = CardData.GetCard(CardToSearchFor);
                if (WhichCard == null)
                {
                    return(Histories);
                }
                var CardHistories = from c in GiftEntity.Histories
                                                                           //join c2 in GiftEntity.Cards on c.Card2 equals c2.ID
                                    where c.CardGUID == WhichCard.CardGUID //||
                                                                           //c.Card2 == WhichCard.ID
                                    select new
                {
                    ID         = c.ID,
                    CardGUID   = c.CardGUID,
                    TransType  = c.TransType,
                    When       = c.WhenHappened,
                    Amount     = c.Amount,
                    MerchWhere = c.WhichMerchantGUID,
                    Clrk       = c.Clerk,
                    Text       = c.TransactionText,
                    //Card2 = c2.CardNumber,
                    InvoiceNumber = c.InvoiceNumber
                };

                // need to restructure what we return to the calling program
                if (CardHistories == null)
                {
                    return(Histories);
                }

                foreach (var Hist in CardHistories)
                {
                    string CardNumber = (from c in GiftEntity.Cards
                                         where c.CardGUID == Hist.CardGUID
                                         orderby c.ID descending
                                         select c.CardNumLast4).FirstOrDefault();
                    CardHistory Chist = new CardHistory();
                    Chist.ID         = Hist.ID;
                    Chist.CardNumber = CardNumber;
                    Chist.MerchWhere = (from m in GiftEntity.Merchants
                                        where m.MerchantGUID == Hist.MerchWhere
                                        select m.MerchantName).FirstOrDefault();
                    Chist.Clerk       = Hist.Clrk;
                    Chist.When        = Hist.When;
                    Chist.TransType   = Hist.TransType;
                    Chist.Transaction = ConvertTransactionType(Hist.TransType);
                    Chist.Amount      = Hist.Amount;
                    Chist.Text        = Hist.Text;
                    //Chist.Card2 = Hist.Card2;
                    Chist.InvoiceNumber = Hist.InvoiceNumber;
                    Histories.Add(Chist);
                }
                return(Histories);
            }
        }
示例#2
0
        public ActionResult Create([Bind(Include = "ID,number,state,expirationDate")] Card card)
        {
            ServiceReference2.Service1Client service1Client1 = new ServiceReference2.Service1Client();

            Random rnd          = new Random();
            string randomNumber = "";

            for (int i = 0; i < 19; i++)
            {
                randomNumber += rnd.Next(0, 9).ToString();
            }
            var cardModel = new Card()
            {
                number         = randomNumber,
                state          = State.Registered,
                expirationDate = DateTime.Now.AddYears(10)
            };

            var cardHistoryModel = new CardHistory()
            {
                state           = State.Registered,
                acquisitionDate = DateTime.Now,
                stateChangeDate = DateTime.Now,
                card            = cardModel
            };

            db.Cards.Add(cardModel);
            db.CardHistories.Add(cardHistoryModel);
            db.SaveChanges();

            //calling the service method.
            service1Client1.GetStringData(randomNumber);

            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult History([Bind(Include = "cardHistoryID, state, acquisitionDate, stateChangeDate, card")] CardHistory cardHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cardHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cardHistory));
 }
        public IActionResult Update(CardHistory cardHistory)
        {
            var result = _cardHistoryService.Update(cardHistory);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        List <CardHistory> IHistoryDAO.GetMerchantHistory(int MerchantToList, int Page, int PageSize)
        {
            using (var GiftEntity = new GiftEntities())
            {
                IMerchantDAO       MerchantData = new MerchantDAO();
                List <CardHistory> Histories    = new List <CardHistory>();
                ICardRepository    CardData     = new CardRepository(GiftEntity);
                Merchant           MerchToList  = MerchantData.GetMerchant(MerchantToList);
                if (MerchToList == null)
                {
                    return(Histories);
                }
                Guid MerchantToListGUID = MerchToList.MerchantGUID;

                var MerchHistories = (from m in GiftEntity.Histories
                                      where m.WhichMerchantGUID == MerchantToListGUID
                                      orderby m.ID descending
                                      select m
                                      ).Skip(Page * PageSize).Take(PageSize);

                // need to restructure what we return to the calling program
                if (MerchHistories == null)
                {
                    return(Histories);
                }

                foreach (var Hist in MerchHistories)
                {
                    string CardNumber = (from c in GiftEntity.Cards
                                         where c.CardGUID == Hist.CardGUID
                                         select c.CardNumLast4).FirstOrDefault();
                    CardHistory Chist = new CardHistory();
                    Chist.ID         = Hist.ID;
                    Chist.CardNumber = CardNumber;
                    Chist.MerchWhere = (from m in GiftEntity.Merchants
                                        where m.MerchantGUID == Hist.WhichMerchantGUID
                                        select m.MerchantName).FirstOrDefault();
                    Chist.Clerk       = Hist.Clerk;
                    Chist.When        = Hist.WhenHappened;
                    Chist.TransType   = Hist.TransType;
                    Chist.Transaction = ConvertTransactionType(Hist.TransType);
                    Chist.Amount      = Hist.Amount;
                    Chist.Text        = Hist.TransactionText;
                    //Chist.Card2 = Hist.Card2;
                    Chist.InvoiceNumber = Hist.InvoiceNumber;
                    Histories.Add(Chist);
                }
                return(Histories);
            }
        }
示例#6
0
        public ActionResult Block(int?id)
        {
            Card        card        = db.Cards.Find(id);
            CardHistory cardHistory = new CardHistory();

            cardHistory.acquisitionDate = DateTime.Now;
            cardHistory.stateChangeDate = DateTime.Now;
            cardHistory.card            = card;
            if (card == null)
            {
                return(RedirectToAction("Error"));
            }
            if (card.state == State.Registered || card.state == State.Active)
            {
                switch ((int)card.state)
                {
                case 0:
                    card.state        = State.Blocked;
                    cardHistory.state = State.Blocked;
                    db.CardHistories.Add(cardHistory);
                    db.SaveChanges();
                    break;

                case 1:
                    card.state        = State.Blocked;
                    cardHistory.state = State.Blocked;
                    db.CardHistories.Add(cardHistory);
                    db.SaveChanges();
                    break;

                case 2:
                    break;

                case 3:
                    break;

                default:
                    break;
                }
            }
            else
            {
            }

            return(RedirectToAction("Index"));
        }
示例#7
0
        public async Task Execute(IJobExecutionContext context)
        {
            CardContext db = new CardContext();

            List <Card> cards = db.Set <Card>().Where(card => card.expirationDate <= DateTime.Now && card.state != State.Expired).ToList();

            foreach (Card card in cards)
            {
                CardHistory cardHistory = new CardHistory();

                card.state = State.Expired;

                cardHistory.acquisitionDate = DateTime.Now;
                cardHistory.stateChangeDate = DateTime.Now;
                cardHistory.card            = card;
                db.CardHistories.Add(cardHistory);
            }
            db.SaveChanges();
        }
示例#8
0
        public ActionResult Unblock(int?id)
        {
            Card        card        = db.Cards.Find(id);
            CardHistory cardHistory = new CardHistory();

            cardHistory.acquisitionDate = DateTime.Now;
            cardHistory.stateChangeDate = DateTime.Now;
            cardHistory.card            = card;

            if (card == null)
            {
                return(RedirectToAction("Error"));
            }
            if (card.state == State.Blocked)
            {
                card.state        = State.Active;
                cardHistory.state = State.Active;
                db.CardHistories.Add(cardHistory);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#9
0
        private void InitGame()
        {
            this.cardHUD = new CardHUD(0, 0, (int)GodClass.CardHUDdimensions.GetHeight(),
                                       (int)GodClass.CardHUDdimensions.GetWidth(),
                                       this.gameplayLayer);
            this.cardHistory = new CardHistory((int)(GodClass.BattlefieldDimensions.GetWidth() * 0.4)
                                               , (int)(BattlefieldDimensions.GetHeight() * 0.95)
                                               , (int)(GodClass.BattlefieldDimensions.GetHeight())
                                               , (int)GodClass.BattlefieldDimensions.GetWidth()
                                               , this.gameplayLayer);
            this.battlefield = new UIcontainer(0,
                                               (int)GodClass.CardHUDdimensions.GetHeight(),
                                               (int)GodClass.BattlefieldDimensions.GetHeight(),
                                               (int)GodClass.BattlefieldDimensions.GetWidth(),
                                               this.gameplayLayer);
            GodClass.battlefield = battlefield;
            GodClass.cardHUD     = this.cardHUD;
            GodClass.cardHistory = this.cardHistory;

            gameplayLayer.AddChild(battlefield);
            gameplayLayer.AddChild(cardHUD);
            gameplayLayer.AddChild(cardHistory);
            targetLines = new List <CCDrawNode>();

            GodClass.gameplayLayer = gameplayLayer;
            GodClass.hudLayer      = hudLayer;
            GodClass.InitLibrary();

            InitGridManager();

            this.InitTeams();

            //InitScrollMap();

            GamesState = GameState.Playing;
        }
示例#10
0
        public async Task <ActionResult> Order(CardHistory model)
        {
            //string pwd = SecurityHelper.MD5(Request.Params["opratepwd"]);
            var user = CurrentLoginUser;
            //if (pwd.Equals(user.OpratePwd))
            {
                var card = await _repositoryFactory.IMemberCard.SingleAsync(m => m.Status == (int)EnumHepler.MemberCardStatus.Available && m.CardNo.Equals(model.CardNo));

                if (card != null)
                {
                    //查找是否有优惠
                    var promote = GetAvailablePromotion(EnumHepler.PromotionType.Consume, model.Value);
                    if (promote != null)
                    {
                        model.PromotionValue = promote.Money.Value;
                        model.Remark        += $" <br /> P:[{promote.Title}] 优惠{promote.Money}元";
                    }
                    model.PracticalValue = model.Value - model.PromotionValue;
                    if (card.Banlance < model.PracticalValue)
                    {
                        return(ShowResultMessage(new TipMessage()
                        {
                            Status = false, MsgText = $"会员卡余额不足!折扣:{model.PromotionValue},待支付:{model.PracticalValue}"
                        }));
                    }
                    //写消费记录
                    model.Type       = (int)EnumHepler.BillType.Pay;
                    model.CreateTime = DateTime.Now;
                    model.CreateUser = user.UserName;
                    _repositoryFactory.ICardHistory.Add(model);
                    //更新会员卡信息
                    card.Banlance      -= model.PracticalValue; //余额
                    card.TotalDiscount += model.PromotionValue; //累计折扣
                    //写系统日志
                    WriteLog($"管理员[{user.UserName}]为会员卡[{model.CardNo}]消费{model.Value}元,备注:{model.Remark}");
                    //保存数据
                    if (await _repositoryFactory.SaveChanges() > 0)
                    {
                        return(ShowResultMessage(new TipMessage()
                        {
                            Status = true, MsgText = $"消费成功!{(model.PromotionValue > 0 ? $"本次省下{model.PromotionValue}元" : "")}"
                        }, "ClearConsume();"));
                    }
                    else
                    {
                        return(ShowResultMessage(new TipMessage()
                        {
                            Status = false, MsgText = "消费失败!", Url = Url.Action("Order")
                        }));
                    }
                }
                else
                {
                    return(ShowResultMessage(new TipMessage()
                    {
                        Status = false, MsgText = "查询会员卡失败!"
                    }));
                }
            }
            //else
            //{
            //    return ShowResultMessage(new TipMessage() { Status = false, MsgText = "操作密码错误!" });
            //}
        }
示例#11
0
        public async Task <ActionResult> Charge(CardHistory model)
        {
            string pwd  = SecurityHelper.MD5(Request.Params["opratepwd"]);
            var    user = CurrentLoginUser;

            if (pwd.Equals(user.OpratePwd))
            {
                var card = await _repositoryFactory.IMemberCard.SingleAsync(m => m.Status == (int)EnumHepler.MemberCardStatus.Available && m.CardNo.Equals(model.CardNo));

                if (card != null)
                {
                    //写充值记录
                    model.Type       = (int)EnumHepler.BillType.Charge;
                    model.CreateTime = DateTime.Now;
                    model.CreateUser = user.UserName;
                    model.Remark     = $"管理员[{user.UserName}]为会员卡[{model.CardNo}]充值{model.Value}元";
                    //查找是否有优惠
                    var promote = GetAvailablePromotion(EnumHepler.PromotionType.Charge, model.Value);
                    if (promote != null)
                    {
                        model.PromotionValue = promote.Money.Value;
                        model.Remark        += $"<br /> P:[{promote.Title}] 赠送{promote.Money}元";
                    }
                    model.PracticalValue = model.Value + model.PromotionValue;
                    _repositoryFactory.ICardHistory.Add(model);
                    //更新会员卡信息
                    card.Banlance     += model.PracticalValue; //余额
                    card.TotalMoney   += model.Value;          //累计充值
                    card.TotalPresent += model.PromotionValue; //累计赠送
                    //写系统日志
                    WriteLog(model.Remark);
                    //保存数据
                    if (await _repositoryFactory.SaveChanges() > 0)
                    {
                        return(ShowResultMessage(new TipMessage()
                        {
                            Status = true, MsgText = "充值成功!"
                        }, "ClearCharge();"));
                    }
                    else
                    {
                        return(ShowResultMessage(new TipMessage()
                        {
                            Status = false, MsgText = "充值失败!", Url = Url.Action("Charge")
                        }));
                    }
                }
                else
                {
                    return(ShowResultMessage(new TipMessage()
                    {
                        Status = false, MsgText = "查询会员卡失败!"
                    }));
                }
            }
            else
            {
                return(ShowResultMessage(new TipMessage()
                {
                    Status = false, MsgText = "操作密码错误!"
                }));
            }
        }
示例#12
0
 public IResult Update(CardHistory cardHistory)
 {
     _cardHistoryDal.Update(cardHistory);
     return(new SuccessResult(Messages.CardHistoryUpdate));
 }
示例#13
0
 public IResult Add(CardHistory cardHistorydal)
 {
     _cardHistoryDal.Add(cardHistorydal);
     return(new SuccessResult(Messages.CardHistoryAdded));
 }
示例#14
0
        public void AddGameHistory(List <CardHistory> historyList, Gamer gamer, OneCard oneCard)
        {
            var newRecord = new CardHistory(gamer.Name, gamer.Points, oneCard);

            historyList.Add(newRecord);
        }
        List <CardHistory> IHistoryDAO.GetCardHistory(int CardID)
        {
            InitializeConnection();
            List <CardHistory> Histories = new List <CardHistory>();
            ICardRepository    CardData  = new CardRepository(GiftEntity);
            Card WhichCard = CardData.GetCard(CardID);

            if (WhichCard == null)
            {
                return(Histories);
            }
            var CardHistories = from c in GiftEntity.Histories
                                //join c2 in GiftEntity.Cards on c.Card2 equals c2.ID
                                where c.CardGUID == WhichCard.CardGUID &&
                                c.ErrorCode == "APP  " &&
                                (c.TransType == "ACTV" ||
                                 c.TransType == "SALE" ||
                                 c.TransType == "GTIP" ||
                                 c.TransType == "CRED" ||
                                 c.TransType == "BALN" ||
                                 c.TransType == "TRAN" ||
                                 c.TransType == "TPUP" ||
                                 c.TransType == "LYSL" ||
                                 c.TransType == "LYCR" ||
                                 c.TransType == "LYRM" ||
                                 c.TransType == "LYPR" ||
                                 c.TransType == "LEVT" ||
                                 c.TransType == "LVST" ||
                                 c.TransType == "CUCR" ||
                                 c.TransType == "CUDB" ||
                                 c.TransType == "DEPL")
                                //||
                                //c.Card2 == WhichCard.ID
                                select new
            {
                ID         = c.ID,
                CardGUID   = c.CardGUID,
                TransType  = c.TransType,
                When       = c.WhenHappened,
                Amount     = c.Amount,
                MerchWhere = c.WhichMerchantGUID,
                Clrk       = c.Clerk,
                Text       = c.TransactionText,
                //Card2 = c2.CardNumber,
                InvoiceNumber = c.InvoiceNumber
            };

            // need to restructure what we return to the calling program
            if (CardHistories == null)
            {
                return(Histories);
            }

            foreach (var Hist in CardHistories)
            {
                string CardNumber = (from c in GiftEntity.Cards
                                     where c.CardGUID == Hist.CardGUID
                                     orderby c.ID descending
                                     select c.CardNumLast4).FirstOrDefault();
                CardHistory Chist = new CardHistory();
                Chist.ID         = Hist.ID;
                Chist.CardNumber = CardNumber;
                Chist.MerchWhere = (from m in GiftEntity.Merchants
                                    where m.MerchantGUID == Hist.MerchWhere
                                    select m.MerchantName).FirstOrDefault();
                Chist.Clerk       = Hist.Clrk;
                Chist.When        = Hist.When;
                Chist.TransType   = Hist.TransType;
                Chist.Transaction = ConvertTransactionType(Hist.TransType);
                Chist.Amount      = Hist.Amount;
                Chist.Text        = Hist.Text;
                //Chist.Card2 = Hist.Card2;
                Chist.InvoiceNumber = Hist.InvoiceNumber;
                Histories.Add(Chist);
            }
            return(Histories);
        }
        // Yes, there was a stored procedure to do the detail report,
        // but it returns two result sets and the second one can have
        // a bunch of records in it.
        DetailHistory IHistoryDAO.DetailReport(String MerchantID, String ClerkID, String WhereFrom, String MerchSeqNum, String TerminalID, DateTime LocalTime)
        {
            InitializeConnection();
            // need to resolve any merchant sequence number issues



            DetailHistory Results = new DetailHistory();

            Results.DetailItems = new List <CardHistory>();


            gp_DailyReport_Result Res = GiftEntity.gp_DailyReport(MerchantID, ClerkID, "E", WhereFrom, MerchSeqNum, TerminalID, LocalTime).FirstOrDefault();

            if (Res.ResponseCode == "A")
            {
                Results.When         = DateTime.Now;
                Results.ResponseCode = Res.ResponseCode[0];
                Results.ErrorCode    = (string)Res.ErrorCode;
                Results.Summary      = new DailySalesInformation();
                DailyReportToWeb(Res, Results.Summary, LocalTime);


                // now get the details

                Merchant Merch = GiftEntity.Merchants.FirstOrDefault(d => d.MerchantID == MerchantID);

                var LastRun = (from h in GiftEntity.Histories
                               where h.WhichMerchantGUID == Merch.MerchantGUID &&
                               h.TransType == "CLOS"
                               orderby h.ID descending
                               select h.ID).FirstOrDefault();
                //if (LastRun == null)
                //    LastRun = 0;

                var DailyHistories = from h in GiftEntity.Histories
                                     where h.WhichMerchantGUID == Merch.MerchantGUID &&
                                     h.ID > LastRun &&
                                     h.ErrorCode == "APP  " &&
                                     h.TransType != "DYRP" && // keep the daily report out of this
                                     h.TransType != "SHIP"    // keep the card shipments out of the report
                                     orderby h.ID
                                                              //c.Card2 == WhichCard.ID
                                     select new
                {
                    ID               = h.ID,
                    CardGUID         = h.CardGUID,
                    TransType        = h.TransType,
                    When             = h.WhenHappened,
                    LocalTime        = h.LocalTime,
                    Amount           = h.Amount,
                    PointsGranted    = 0,
                    MerchWhere       = h.WhichMerchantGUID,
                    Clrk             = h.Clerk,
                    Text             = h.TransactionText,
                    CardGUID2        = h.CardGUID2,
                    CouponUsed       = 0,
                    CouponIssued     = 0,
                    PrizeAwardedGUID = Guid.NewGuid(),
                    InvoiceNumber    = h.InvoiceNumber
                };
                foreach (var his in DailyHistories)
                {
                    CardHistory nHistory = new CardHistory();
                    nHistory.ID         = his.ID;
                    nHistory.CardNumber = (from c in GiftEntity.Cards
                                           where c.CardGUID == his.CardGUID
                                           select c.CardNumLast4).FirstOrDefault().ToString();
                    nHistory.Amount     = his.Amount;
                    nHistory.Clerk      = his.Clrk;
                    nHistory.MerchWhere = (from m in GiftEntity.Merchants
                                           where m.MerchantGUID == his.MerchWhere
                                           select m.MerchantName).FirstOrDefault();
                    nHistory.TransType   = his.TransType;
                    nHistory.Transaction = ConvertTransactionType(his.TransType);
                    nHistory.When        = his.When;
                    if (his.LocalTime.HasValue)
                    {
                        nHistory.LocalTime = his.LocalTime.Value;
                    }
                    nHistory.Text          = his.Text;
                    nHistory.PointsGranted = his.PointsGranted;
                    if (his.CardGUID2 != null)
                    {
                        nHistory.Card2 = GiftEntity.Cards
                                         .FirstOrDefault(c => c.CardGUID == his.CardGUID2).CardNumLast4;
                    }
                    nHistory.InvoiceNumber = his.InvoiceNumber;

                    Results.DetailItems.Add(nHistory);
                }
            }
            else
            {
                Results.ResponseCode = Res.ResponseCode[0];
                Results.ErrorCode    = (string)Res.ErrorCode;
            }
            return(Results);
        }
示例#17
0
 public IList <CardHistoryData> GetAllHistory(Guid id)
 {
     return(CardHistory.ToJavaScriptCardHistory(_eventStoreRepository.All(id)));
 }