Пример #1
0
        //public async Task<LoanApplication> UpdateAsync(LoanApplication loanApplication, CancellationToken ct)
        //{
        //    var updatedLoanApplicationEntry = this.context.LoanApplications.Update(loanApplication.ToEntity());
        //    await this.context.SaveChangesAsync(ct);
        //    return updatedLoanApplicationEntry.Entity.ToService();
        //}

        public async Task <LoanApplication> UpdateAsync(LoanApplication loanApplication, CancellationToken cancellationToken)
        {
            var existingLoanApplication = await this.context.LoanApplications.SingleOrDefaultAsync(application => application.Id.Equals(loanApplication.Id), cancellationToken);

            this.context.Entry(existingLoanApplication).CurrentValues.SetValues(loanApplication.ToEntity());
            await this.context.SaveChangesAsync();

            return(existingLoanApplication.ToService());
        }
Пример #2
0
        public async Task <bool> AddAsync(LoanApplication loanApplication, CancellationToken cancellationToken)
        {
            var application = loanApplication.ToEntity();

            application.ApplicationStatusId = -1;
            //application.OpenedById = loanApplication.OpenedById;

            var addedLoanApplicationEntry = this.context.LoanApplications.Add(application);

            await this.context.SaveChangesAsync(cancellationToken);

            return(true);
        }