コード例 #1
0
        public void DeleteDocument(CommissionDocument document)
        {
            try
            {
                CheckDeleteRight();
                Context.CommissionTransactions.Delete(document.Id);
                var dleteCardIds = Context.CardsTrancport
                                   .All()
                                   .Where(x => x.CommissionTransaction.Id == document.Id)
                                   .Select(x => x.Id).ToArray();
                Context.CardsTrancport
                .DeleteRange(dleteCardIds);
                Context.SaveChanges();
            }
            catch (AccessDeniedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(ex);

                throw new Exception("Неудалось удалить документ");
            }
        }
コード例 #2
0
        public void SaveDocument(CommissionDocument document)
        {
            try
            {
                CheckAddRight();

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

                throw new Exception("Неудалось сохранить документ");
            }
        }
コード例 #3
0
        public Response DeleteCommission(CommissionDocument document)
        {
            try
            {
                _WriteLineConsole($"delete commission identity: {document.Identity}");
                using (var helper = new CommissionHelper())
                {
                    helper.DeleteCommission(document);
                }

                return(new Response()
                {
                    Message = "Документ удален"
                });
            }
            catch (Exception ex)
            {
                _WriteLineError($"delete commission identity: {document?.Identity}", ex.Message);
                return(new Response(ex));
            }
        }
コード例 #4
0
        public SaveEntityResult SaveCommission(CommissionDocument document)
        {
            try
            {
                _WriteLineConsole($"save commission identity: {document.Identity}");
                using (var helper = new CommissionHelper())
                    helper.SaveCommision(document);

                return(new SaveEntityResult()
                {
                    Message = "Данные успешно сохраненны", Id = document.Id, Number = document.Number
                });
            }
            catch (Exception ex)
            {
                _WriteLineError($"save commission identity: {document?.Identity}", ex.Message);
                return(new SaveEntityResult()
                {
                    Error = true,
                    Message = ex.Message
                });
            }
        }
コード例 #5
0
 public void SaveCommision(CommissionDocument document)
 {
     _logic.SaveDocument(document);
 }
コード例 #6
0
 public void DeleteCommission(CommissionDocument document)
 {
     _logic.DeleteDocument(document);
 }