private EditQuoteVm GetEditQuoteVM(int id = -1) { var vm = new EditQuoteVm { Kids = GetKidsForParent(Context.CurrentUser.UserName), SaidAt = DateTime.Now }; var quote = db.Quotes.FindById(id); if (quote != null) { vm.Id = quote.Id; vm.SaidAt = quote.SaidAt; vm.Quote = quote.Quote; vm.KidId = quote.KidId; } return vm; }
private int SaveOrUpdateQuote(EditQuoteVm quoteInfo) { int id; if (quoteInfo.Id != 0) { db.Quotes.Update(quoteInfo); id = quoteInfo.Id; } else id = db.Quotes.Insert(quoteInfo).Id; return id; }