public async Task <IActionResult> EditOperatingExpense([FromBody] OperatingExpense operatingExpense) { if (operatingExpense == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); return(Json( new { msg = "Fail" })); }
public async Task <IActionResult> AddOperatingExpense([FromBody] OperatingExpense operatingExpense) { var orgId = getOrg(); if (operatingExpense != null) { operatingExpense.Id = Guid.NewGuid(); operatingExpense.OrganisationId = orgId; var expenseType = _context.Expenses.Where(x => x.Id == operatingExpense.ExpenseId).FirstOrDefault().ExpenseType; if (expenseType == null) { expenseType = "Others"; } try { _context.Add(operatingExpense); _context.SaveChanges(); Cashflow credit = new Cashflow() { Id = Guid.NewGuid(), FlowType = "OE", FlowTypeId = operatingExpense.Id, DebitCredit = "C", FlowDetails = "Operating Expenses - " + expenseType + " " + operatingExpense.Description, Amount = operatingExpense.Amount, OrganisationId = orgId }; _context.Add(credit); await _context.SaveChangesAsync(); Transaction tCredit = new Transaction() { Id = Guid.NewGuid(), TransactionType = "OE", TransactionId = operatingExpense.Id, DebitCredit = "C", TransactionDetails = "Operating Expenses - " + expenseType + " " + operatingExpense.Description, Amount = operatingExpense.Amount, OrganisationId = orgId }; _context.Add(tCredit); await _context.SaveChangesAsync(); return(Json(new { msg = "Success" })); } catch { return(Json(new { msg = "Failed" })); } } return(Json(new { msg = "No Data" })); }