예제 #1
0
        public bool Edit(Anticipation anticipation)
        {
            var anticipationModel = _drive.Anticipation.First(a => a.Id == anticipation.Id);

            anticipationModel.Update(anticipation, false);
            return(_drive.SaveChanges() > 0);
        }
 public AnticipationJson(Anticipation anticipation)
 {
     Id                   = anticipation.Id;
     AnalyzeDate          = anticipation.AnalyzeDate;
     AnticipationStatusId = anticipation.AnticipationStatusId;
     AnalyzeResult        = anticipation.AnalyzeResult;
     CreatedAt            = anticipation.CreatedAt;
     RequestedAmount      = anticipation.RequestedAmount.ToCurrency();
     TransferAmount       = (anticipation.TransferAmount).ToCurrency();
 }
예제 #3
0
        public Anticipation Approved(Anticipation anticipation)
        {
            var anticipationModel =
                _drive.Anticipation
                .Include("Transactions.Installments")
                .First(a => a.Id == anticipation.Id);

            anticipationModel.Update(anticipation);
            _drive.SaveChanges();
            return(Find(anticipation.Id));
        }
예제 #4
0
        public async Task <bool> StartAnalysis(AnticipationModel model)
        {
            Anticipation = await _dbContext.Anticipations
                           .WhereId(model.Id)
                           .SingleOrDefaultAsync();

            Anticipation.AnticipationStatusId = (int)AnticipationStatusEnum.Analyzing;

            _dbContext.Update(Anticipation);

            return(await _dbContext.SaveChangesAsync() > 0);
        }
예제 #5
0
 private AnticipationModel ToModel(Anticipation anticipation)
 {
     return(new AnticipationModel
     {
         AnticipatedAmount = anticipation.AnticipatedAmount,
         RequestedAmount = anticipation.RequestedAmount,
         ResultAnalysis = anticipation.ResultAnalysis,
         SolicitationDate = anticipation.SolicitationDate,
         StatusAnticipation = anticipation.StatusAnticipation,
         AnalysisEndDate = anticipation.AnalysisEndDate,
         AnalysisStartDate = anticipation.AnalysisStartDate
     });
 }
        public Guid CreateAnticipation(IEnumerable <Transaction> transactions)
        {
            if (AnticipationInOpen())
            {
                throw new ForbiddenException("Já existe uma antecipação em aberto");
            }

            var enumerable   = transactions.ToList();
            var anticipation = new Anticipation(DateTime.Now,
                                                enumerable.Sum(t => t.NetValue),
                                                enumerable.ToList());

            return(_repository.Save(anticipation));
        }
예제 #7
0
 public Guid Save(Anticipation anticipation)
 {
     _drive.Database.BeginTransaction();
     try
     {
         var model = ToModel(anticipation);
         var nsus  = anticipation.Transactions.Select(at => at.NSU);
         model.Transactions = _drive.Transaction
                              .Where(t => nsus.Contains(t.NSU))
                              .ToList();
         _drive.Anticipation.Add(model);
         _drive.SaveChanges();
         _drive.Database.CommitTransaction();
         return(model.Id);
     }
     catch (Exception)
     {
         _drive.Database.RollbackTransaction();
         throw new Exception("Erro ao salvar antecipação");
     }
 }
예제 #8
0
        public async Task <bool> Process(RequestAnticipationModel model)
        {
            Anticipation = model.Map();

            var transferAmount = (decimal)0.0;

            foreach (var item in model.Transactions)
            {
                transferAmount += item.TransactionAmount.CalculateTransactionFees(item.Installments);

                Anticipation.AnticipationItems.Add(new AnticipationItem {
                    AnticipationId = Anticipation.Id,
                    TransactionId  = item.Id
                });
            }

            Anticipation.TransferAmount = transferAmount - AmountTransactionFee;

            _dbContext.Add(Anticipation);

            return(await _dbContext.SaveChangesAsync() > 0);
        }
예제 #9
0
 public Anticipation Reproved(Anticipation anticipation)
 {
     Edit(anticipation);
     return(Find(anticipation.Id));
 }
예제 #10
0
 public AnticipationAlreadyInProgress(Anticipation anticipationInProgress)
 {
     AnticipationInProgress = anticipationInProgress;
     Message = "There is an anticipation in progress.";
 }
예제 #11
0
 public Anticipation Reproved(Anticipation anticipation)
 {
     return(anticipation);
 }
예제 #12
0
 public bool Edit(Anticipation anticipation)
 {
     return(_edit);
 }
예제 #13
0
 public Guid Save(Anticipation anticipation)
 {
     return(new Guid());
 }