public ActionResult Expense_Create([DataSourceRequest] DataSourceRequest request, IncomeExpenseViewModel expense) { if (ModelState.IsValid) { var entity = new Expense { AgentId = AuthenticationHelper.AuthenticationHelper.GetAgentId(), Amount = expense.Amount, Observations = expense.Observations, CreatedDate = DateTime.UtcNow, UpdateDate = DateTime.UtcNow, MovementTypeId = expense.MovementTypeId, BankAccountId = Convert.ToInt16(HttpContext.Request["bankAccountId"]) }; _db.Expense.Add(entity); _db.SaveChanges(); expense.Id = entity.Id; } return(Json(new[] { expense }.ToDataSourceResult(request, ModelState))); }
public ActionResult Expense_Update([DataSourceRequest] DataSourceRequest request, IncomeExpenseViewModel expense) { if (ModelState.IsValid) { var entity = new Expense { AgentId = AuthenticationHelper.AuthenticationHelper.GetAgentId(), Id = expense.Id, Amount = expense.Amount, Observations = expense.Observations, CreatedDate = expense.CreatedDate.ToUniversalTime(), UpdateDate = DateTime.UtcNow, MovementTypeId = expense.MovementTypeId, BankAccountId = expense.BankAccountId }; _db.Expense.Attach(entity); _db.Entry(entity).State = EntityState.Modified; _db.SaveChanges(); } return(Json(new[] { expense }.ToDataSourceResult(request, ModelState))); }
public ActionResult Expense_Destroy([DataSourceRequest] DataSourceRequest request, IncomeExpenseViewModel serviceMovement) { _dbAdoRepository.DeleteItemById(serviceMovement.Id, "Expense"); return(Json(new[] { serviceMovement }.ToDataSourceResult(request, ModelState))); }
public ActionResult Income_Destroy([DataSourceRequest] DataSourceRequest request, IncomeExpenseViewModel serviceMovement) { try { _dbAdoRepository.DeleteItemById(serviceMovement.Id, "Income"); } catch (Exception ex) { var exMessage = ex.Message; } return(Json(new[] { serviceMovement }.ToDataSourceResult(request, ModelState))); }