public async Task <IActionResult> CreateBillingPost([Bind("Id,Customer,Incident,Started,Ended,Hours,Price,Total,Outlay,PersonId,Notes,WLNumber,BPStatusId,PONumber")] BillingPost billingPost) { if (ModelState.IsValid) { var nBSContext = _context.BillingPost .Include(t => t.BPStatus) .Include(t => t.Employee); billingPost.Total = (billingPost.Hours * billingPost.Price) + billingPost.Outlay; _context.Add(billingPost); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ListBillingPosts))); } ViewData["PersonId"] = new SelectList(_context.Person, "Id", "FullName", billingPost.PersonId); ViewData["BPStatusId"] = new SelectList(_context.BPStatus, "Id", "BPStatusName"); return(View(billingPost)); }
public async Task <IActionResult> EditBillingPostEmployee(int id, [Bind("Id,Customer,Incident,Started,Ended,Hours,Price,Total,Outlay,PersonId,Notes,WLNumber,BPStatusId,PONumber")] BillingPost billingPost) { if (id != billingPost.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var nBSContext = _context.BillingPost .Include(t => t.BPStatus) .Include(t => t.Employee); billingPost.Total = (billingPost.Hours * billingPost.Price) + billingPost.Outlay; _context.Update(billingPost); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BillingPostExists(billingPost.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ListBillingPosts))); } ViewData["PersonId"] = new SelectList(_context.Person, "Id", "FullName", billingPost.PersonId); ViewData["BPStatusId"] = new SelectList(_context.BPStatus, "Id", "BPStatusName", billingPost.BPStatusId); return(View(billingPost)); }