Exemple #1
0
        public void Init(AccountServiceResponse rsp, int dealType)
        {
            Code  = rsp.Code;
            Error = ModelHelper.GetBoundText(this, x => x.Code);
            if (Code == ResponseCode.Success)
            {
                var dealLog = DealLogService.GetById(Convert.ToInt32(rsp.SerialServerNo));
                ShopName       = dealLog.ShopName;
                PosName        = dealLog.SourcePosName;
                AccountName    = dealLog.AccountName;
                Amount         = dealLog.Amount;
                SerialNo       = dealLog.SerialNo;
                ServerSerialNo = dealLog.SerialServerNo;

                if (Code == ResponseCode.Success)
                {
                    var account     = AccountService.GetByName(AccountName);
                    var shop        = ShopService.GetByName(ShopName);
                    var pos         = PosService.GetById(dealLog.SourcePosId);
                    var currentUser = SecurityHelper.GetCurrentUser().CurrentUser;
                    switch (dealType)
                    {
                    case DealTypes.Deal:

                        if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfDeal))
                        {
                            this.Ticket = MessageFormator.FormatTickForDeal(HostSite.TicketTemplateOfDeal, HostSite, dealLog, account, shop, pos, currentUser);
                        }
                        break;

                    case DealTypes.CancelDeal:
                        if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfCancelDeal))
                        {
                            this.Ticket = MessageFormator.FormatTickForDeal(HostSite.TicketTemplateOfCancelDeal, HostSite, dealLog, account, shop, pos, currentUser);
                        }
                        break;
                    }
                }
            }
        }