public void SaveDocument(CashTransactionDocument document)
        {
            try
            {
                CheckAddRight();

                var cashTransaction = TinyMapper.Map <CashTransaction>(document);
                if (cashTransaction.Id == 0)
                {
                    cashTransaction.UserId = User.Id;
                }
                Context.CashTransactions.AddOrUpdate(cashTransaction);
                Context.SaveChanges();
                document.Id = cashTransaction.Id;
                //document.Number = Context.CashTransactions.Get(cashTransaction.Id).Number;
            }
            catch (AccessDeniedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(ex);

                throw new Exception("Неудалось сохранить документ");
            }
        }
        public void DeleteDocument(CashTransactionDocument document)
        {
            try
            {
                CheckDeleteRight();
                Context.CashTransactions.Delete(document.Id);
                Context.SaveChanges();
            }
            catch (AccessDeniedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(ex);

                throw new Exception("Неудалось удалить документ");
            }
        }
Ejemplo n.º 3
0
        public Response DeleteCashTransaction(CashTransactionDocument document)
        {
            try
            {
                _WriteLineConsole($"delete cash transaction identity: {document.Identity}");
                using (var helper = new CashTransactionsHelper())
                {
                    helper.DeleteCashTransaction(document);
                }

                return(new Response()
                {
                    Message = "Документ удален"
                });
            }
            catch (Exception ex)
            {
                _WriteLineError($"delete cash transaction identity: {document?.Identity}", ex.Message);
                return(new Response(ex));
            }
        }
Ejemplo n.º 4
0
        public SaveEntityResult SaveCashTransaction(CashTransactionDocument document)
        {
            try
            {
                _WriteLineConsole($"save cash transaction identity: {document.Identity}");
                using (var helper = new CashTransactionsHelper())
                    helper.SaveCashTransaction(document);

                return(new SaveEntityResult()
                {
                    Message = "Данные успешно сохраненны", Id = document.Id, Number = document.Number
                });
            }
            catch (Exception ex)
            {
                _WriteLineError($"save cash transaction identity: {document?.Identity}", ex.Message);
                return(new SaveEntityResult()
                {
                    Error = true,
                    Message = ex.Message
                });
            }
        }
Ejemplo n.º 5
0
 public void SaveCashTransaction(CashTransactionDocument document)
 {
     _logic.SaveDocument(document);
 }
Ejemplo n.º 6
0
 public void DeleteCashTransaction(CashTransactionDocument document)
 {
     _logic.DeleteDocument(document);
 }