public static SaveExpenseResponse ManageExpenses(ManageExpenseRequest request) //Evaluate an Expense { using (var entities = new ExpenseProjectDBEntities()) { try //Correct? { var expense = entities.Expenses.SingleOrDefault(e => e.ID == request.ExpenseID); if (request.Approved) { if (expense.StatusId == 2) { expense.StatusId = 3; //Status of the expense updates from waiting mng approval to waiting acc approval } else if (expense.StatusId == 3) { expense.StatusId = 5; //What to do with Approved Expenses? } } else { expense.StatusId = 4; expense.RejectDescription = request.RejectDescription; } entities.SaveChanges(); var response = new SaveExpenseResponse(); response.IsSuccess = true; response.Message = "The expense's status has been successfully updated."; return(response); } catch (NullReferenceException) { var response = new SaveExpenseResponse(); response.IsSuccess = false; response.Message = "The expense you're trying to evaluate doesn't exist."; return(response); } } }
public SaveExpenseResponse EvaluateExpense(ManageExpenseRequest request) { return(ExpenseHandler.ManageExpenses(request)); }