Example #1
0
        //Зберігає
        public override bool UpdateReceipt(ReceiptViewModel pReceipt)
        {
            bool Res = false;

            try
            {
                if (pReceipt != null && pReceipt.ReceiptEvents != null)
                {
                    var RE = pReceipt.ReceiptEvents.Select(r => GetReceiptEvent(r));
                    if (RE != null)
                    {
                        Bl.SaveReceiptEvents(RE);
                    }
                    if (pReceipt.ReceiptItems != null)
                    {
                        var WR = pReceipt.ReceiptItems.Where(r => r.Excises != null && r.Excises.Count() > 0).Select(r => GetReceiptWaresFromReceiptItem(new IdReceipt(pReceipt.Id), r));
                        if (WR != null && WR.Count() > 0)
                        {
                            Res = Bl.UpdateExciseStamp(WR);
                        }
                    }
                }
                FileLogger.WriteLogMessage($"ApiPSU.UpdateReceipt =>(pTerminalId=>{pReceipt?.ToJSON()}) => ({Res})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.UpdateReceipt Exception =>(pTerminalId=>{pReceipt?.ToJSON()}) => ({Res}){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.UpdateReceipt", e);
            }
            return(Res);
        }
Example #2
0
        public override ReceiptViewModel GetNoFinishReceipt(Guid pTerminalId)
        {
            ReceiptViewModel Res = null;

            try
            {
                var receipt = Bl.GetLastReceipt(Global.GetIdWorkplaceByTerminalId(pTerminalId));
                if (receipt != null && receipt.StateReceipt == eStateReceipt.Prepare)
                {
                    Receipts[pTerminalId] = new ModelMID.Receipt(receipt);
                    Res = GetReceiptViewModel(receipt);
                }
                FileLogger.WriteLogMessage($"ApiPSU.GetNoFinishReceipt =>( pTerminalId=>{pTerminalId}) => ({Res?.ToJSON()})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.GetNoFinishReceipt Exception =>( pTerminalId=>{pTerminalId}) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.GetNoFinishReceipt", e);
            }
            return(Res);
        }
Example #3
0
        public override ReceiptViewModel GetReciept(Guid pReceipt)
        {
            ReceiptViewModel Res = null;

            try
            {
                Res = GetReceiptViewModel(new IdReceipt(pReceipt));
                FileLogger.WriteLogMessage($"ApiPSU.GetReciept =>(pReceipt=>{pReceipt})=>({Res?.ToJSON()})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.GetReciept Exception =>(pReceipt=>{pReceipt}) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.GetReciept", e);
            }
            return(Res);
        }
Example #4
0
        public override ReceiptViewModel GetRecieptByTerminalId(Guid pTerminalId, bool pIsDetail = false)
        {
            ReceiptViewModel Res = null;

            try
            {
                var receiptId = GetCurrentReceiptByTerminalId(pTerminalId);
                Res = GetReceiptViewModel(receiptId, pIsDetail);
                FileLogger.WriteLogMessage($"ApiPSU.GetRecieptByTerminalId =>(pTerminalId=>{pTerminalId},pIsDetail={pIsDetail})=>({Res?.ToJSON()})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.GetRecieptByTerminalId Exception =>(pTerminalId=>{pTerminalId},pIsDetail={pIsDetail}) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.GetRecieptByTerminalId", e);
            }
            return(Res);
        }
Example #5
0
        public override ReceiptViewModel ChangeQuantity(Guid pTerminalId, Guid pProductId, decimal pQuantity)
        {
            ReceiptViewModel Res = null;

            try
            {
                var CurReceipt      = GetCurrentReceiptByTerminalId(pTerminalId);
                var CurReceiptWares = new IdReceiptWares(CurReceipt, pProductId);

                if (Bl.ChangeQuantity(CurReceiptWares, pQuantity))
                {
                    Res = GetReceiptViewModel(CurReceipt);
                }
                FileLogger.WriteLogMessage($"ApiPSU.AddProductByProductId =>(pTerminalId=>{pTerminalId},pProductId=>{pProductId},pQuantity={pQuantity})=>({Res?.ToJSON()})", eTypeLog.Full);
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"ApiPSU.AddProductByProductId Exception =>(pTerminalId=>{pTerminalId},pProductId=>{pProductId},pQuantity={pQuantity}) => (){Environment.NewLine}Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                throw new Exception("ApiPSU.ChangeQuantity", e);
            }
            return(Res);
        }