public async Task <IActionResult> OnPostAddTask(decimal totalHours, decimal totalPrice, string taskTitle, int quoteID) { if (!ModelState.IsValid) { return(Page()); } QuoteModelList = await _context.QuoteModel.ToListAsync(); TaskModel.totalHours = totalHours; TaskModel.totalPrice = totalPrice; TaskModel.Title = taskTitle; TaskModel.quoteID = quoteID; foreach (var item in QuoteModelList) { if (item.ID == quoteID) { item.totalHours += totalHours; item.totalCost += totalPrice; } } _context.TaskModel.Add(TaskModel); await _context.SaveChangesAsync(); return(RedirectToPage("/Forms/AddQuote")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostNewQuote() { if (!ModelState.IsValid) { return(Page()); } QuoteModel.dateCreated = DateTime.Now; QuoteModel.totalCost = 0; QuoteModel.totalHours = 0; _context.QuoteModel.Add(QuoteModel); await _context.SaveChangesAsync(); return(RedirectToPage("/Forms/AddQuote")); }