public async Task UpdateAsync(CreditRating creditRatingToSave) { Stopwatch timespan = Stopwatch.StartNew(); try { db.Entry(creditRatingToSave).State = EntityState.Modified; await db.SaveChangesAsync(); timespan.Stop(); log.TraceApi("SQL Database", "CreditRatingRepository.UpdateAsync", timespan.Elapsed, "creditRatingToSave={0}", creditRatingToSave); } catch (Exception e) { log.Error(e, "Error in CreditRatingRepository.UpdateAsync(creditRatingToSave={0})", creditRatingToSave); throw; } }
public async Task CreateAsync(CreditRating creditRatingToAdd) { Stopwatch timespan = Stopwatch.StartNew(); try { db.CreditRatings.Add(creditRatingToAdd); await db.SaveChangesAsync(); timespan.Stop(); log.TraceApi("SQL Database", "CreditRatingRepository.CreateAsync", timespan.Elapsed, "creditRatingToAdd={0}", creditRatingToAdd); } catch (Exception e) { log.Error(e, "Error in CreditRatingRepository.CreateAsync(creditRatingToAdd={0})", creditRatingToAdd); throw; } }
public async Task DeleteAsync(int creditRatingID) { Stopwatch timespan = Stopwatch.StartNew(); try { CreditRating creditRating = await db.CreditRatings.FindAsync(creditRatingID); db.CreditRatings.Remove(creditRating); await db.SaveChangesAsync(); timespan.Stop(); log.TraceApi("SQL Database", "CreditRatingRepository.DeleteAsync", timespan.Elapsed, "creditRatingID={0}", creditRatingID); } catch (Exception e) { log.Error(e, "Error in CreditRatingRepository.DeleteAsync(creditRatingID={0})", creditRatingID); throw; } }
public List <PaymentDeadline> FindPaymentDeadlineByCreditRating(int creditRatingID) { Stopwatch timespan = Stopwatch.StartNew(); try { CreditRating creditRating = db.CreditRatings .Where(p => p.CreditRatingID == creditRatingID).Single(); var result = creditRating.CreditRatingPaymentDeadlines.Select(s => s.PaymentDeadline).OrderBy(s => s.Days).ToList(); timespan.Stop(); log.TraceApi("SQL Database", "CreditRatingPaymentDeadlineRepository.FindPaymentDeadlineByCreditRating", timespan.Elapsed, "creditRatingID={0}", creditRatingID); return(result); } catch (Exception e) { log.Error(e, "Error in CreditRatingPaymentDeadlineRepository.FindPaymentDeadlineByCreditRating(creditRatingID={0})", creditRatingID); throw; } }