public Guid CreateQuote(QuoteDTO newQuote) { try { if (newQuote != null) { var quote = new Quote() { Email = newQuote.Email, FirstName = newQuote.FirstName, LastName = newQuote.LastName, Mobile = newQuote.Mobile, Term = newQuote.Term, Title = newQuote.Title, Amount = newQuote.Amount, CreatedDate = DateTime.UtcNow, CreatedByName = "SYSTEM", LastUpdatedDate = DateTime.UtcNow, LastUpdatedBy = Guid.Empty, LastUpdatedByName = "SYSTEM" }; _moneyMeContext.Quotes.Add(quote); _moneyMeContext.SaveChanges(); CheckLimitQuoteRecordsInDb(); return(quote.Id); } throw new Exception(string.Format("Creating quote for {0} {1}", newQuote.FirstName, newQuote.LastName)); } catch (Exception ex) { throw ex; } }
public void DeleteQuoteDetailsByID(int id) { try { Quote quote = new Quote(); using (var context = new MoneyMeContext()) { quote = context.Quotes.FirstOrDefault(q => q.ID.Equals(id)); if (quote != null) { context.Remove(quote); } context.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public Quote PostQuote(Quote quote) { try { using (var context = new MoneyMeContext()) { Quote foundQuote = context.Quotes.FirstOrDefault(q => q.ID.Equals(quote.ID)); if (foundQuote == null) { context.Quotes.Add(quote); } else { foundQuote.Amount = quote.Amount; foundQuote.EmailAddress = quote.EmailAddress; foundQuote.FirstName = quote.FirstName; foundQuote.LastName = quote.LastName; foundQuote.MobileNo = quote.MobileNo; foundQuote.Rate = quote.Rate; foundQuote.RepaymentMonthly = quote.RepaymentMonthly; foundQuote.RepaymentWeekly = quote.RepaymentWeekly; foundQuote.Term = quote.Term; foundQuote.TermType = quote.TermType; foundQuote.Title = quote.Title; } context.SaveChanges(); } return(quote); } catch (Exception ex) { throw ex; } }