public string InsertExpense(InsertExpense obj) { string returnResult = (dynamic)null; try { if (obj != null) { if (obj.Expenses != null) { var Expenses = new InsertExpenses_Expenses() { Name = obj.Expenses.Name, Amount = obj.Expenses.Amount, Date = obj.Expenses.Date, ExpenseTypeId = obj.Expenses.ExpenseTypeId }; _ExpensesRepo.Insert(Expenses); returnResult = "Saved"; } } } catch (Exception ex) { returnResult = "ERROR102:ClassesServ/InsertClassessList - " + ex.Message; } return(returnResult); }
public async Task <IActionResult> InsertExpense(IndexExpensesListVM obj) { try { if (obj.Expenses != null) { var Expenses = new InsertExpenses_Expenses() { Name = obj.Expenses.Name, Amount = obj.Expenses.Amount, Date = obj.Expenses.Date, ExpenseTypeId = obj.Expenses.ExpenseTypeId, }; var model = new InsertExpense() { Expenses = Expenses }; await Task.Run(() => _ExpensesServ.InsertExpense(model)); } } catch (Exception) { return(BadRequest()); } return(RedirectToAction("ExpensesList")); }
public ActionResult AddNewExpense(InsertExpense model) { int i = 0; if (!ModelState.IsValid) { return(View(model)); } Expense qc = new Expense(); qc.ExpenseName = model.ExpenseName; qc.ExpenseType = model.ExpenseType; qc.ExpenseDate = model.ExpenseDate; qc.Description = model.Description; qc.PaymentMode = model.PaymentMode; HttpPostedFileBase file = Request.Files["ImageData"]; if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Images/") + file.FileName); } qc.PaymentModeNo = model.PaymentModeNo; qc.BranchID = branchID; qc.CreatedBy = userName; qc.CreatedDate = DateTime.Now; i = _ExpenseService.InsertExpense(qc); if (i > 0) { return(RedirectToAction("ExpenseList")); } else { return(View(model)); } }