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(); }
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)); }
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); }
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)); }
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"); } }
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); }
public Anticipation Reproved(Anticipation anticipation) { Edit(anticipation); return(Find(anticipation.Id)); }
public AnticipationAlreadyInProgress(Anticipation anticipationInProgress) { AnticipationInProgress = anticipationInProgress; Message = "There is an anticipation in progress."; }
public Anticipation Reproved(Anticipation anticipation) { return(anticipation); }
public bool Edit(Anticipation anticipation) { return(_edit); }
public Guid Save(Anticipation anticipation) { return(new Guid()); }