public async Task <IActionResult> Create(CostExpenseModel costexpense) { if (ModelState.IsValid) { try { _context.Add(costexpense); await _context.SaveChangesAsync(); } catch (Exception) { return(BadRequest(new { error = "There was an error creating this costexpense" })); } } return(Ok(costexpense)); }
public async Task <IActionResult> Edit(string id, CostExpenseModel costexpense) { if (id != costexpense.ID.ToString()) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(costexpense); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } } return(Ok(costexpense)); }