public IActionResult PostCommentForExpenses(int id, CommentsInput commentInput) { var comment = _mapper.Map <Comments>(commentInput); comment.Expenses = _context.Expenses.Find(id); if (comment.Expenses == null) { return(NotFound()); } _context.Comments.Add(comment); _context.SaveChanges(); return(Ok()); }
private void AddRow_Click(object sender, EventArgs e) { EmployeePayroll employeePayRoll = new EmployeePayroll(); employeePayRoll.EmployeeFirstName = FirstNameInput.Text; employeePayRoll.EmployeeLastName = LastNameInput.Text; employeePayRoll.EmployeeEmail = EmailInput.Text; double PayRate = 0; double.TryParse(PayRateInput.Text, out PayRate); employeePayRoll.EmployeePayRate = PayRate; double Quantity = 0; double.TryParse(QtyInput.Text, out Quantity); employeePayRoll.TaskQty = Quantity; double ExtraPay = 0; double.TryParse(ExtraInput.Text, out ExtraPay); employeePayRoll.EmployeeExtraPay = ExtraPay; double TotalPay = 0; double.TryParse(TotalPayInput.Text, out TotalPay); employeePayRoll.EmployeeTotalPay = TotalPay; employeePayRoll.EmployeeComments = CommentsInput.Text; // Display the new information in the grid from the field. dataGridView1.Rows.Add(FirstNameInput.Text, LastNameInput.Text, EmailInput.Text, PayRate, Quantity, ExtraPay, TotalPay, CommentsInput.Text); dataGridView1.Columns[0].DisplayIndex = 0; // Clear out the input fields FirstNameInput.Clear(); LastNameInput.Clear(); EmailInput.Clear(); PayRateInput.Clear(); QtyInput.Clear(); ExtraInput.Clear(); TotalPayInput.Clear(); CommentsInput.Clear(); }