public async Task <IActionResult> Create(ExpenseIndexViewModel model) { if (ModelState.IsValid) { var objcategory = new Expense { id = model.id , Name = model.Name , isdeleted = false , isactive = false }; _unitofWork.expenses.Add(objcategory); _unitofWork.Save(); TempData["success"] = "Record Save successfully"; return(RedirectToAction(nameof(Index))); } else { return(View()); } }
public ExpenseIndexViewModel ToViewModel(List <Expense> models) { var lsExpenseViewModels = _modelBinder.ToViewModel(models); var viewModel = new ExpenseIndexViewModel(lsExpenseViewModels); return(viewModel); }
public IActionResult Index(ExpenseIndexViewModel model, CoreService core) { model.Suppliers = core.GetSuppliersIEnumerable(); model.Trucks = core.GetTrucksIEnumerable(); model.Stations = core.GetStationsIEnumerable(true); model.Categories = core.GetExpenseCategoriesIEnumerable(); model.Expenses = new List <ExpensesCore>(core.GetExpensesCore(model.Date1x, model.Date2x)); return(View(model)); }
public ExpenseIndexViewModel MapExpenseIndexViewModel(string username) { var expenses = FinancialPlannerRepository.GetExpenses() .Where(m => m.Username == username); var vm = new ExpenseIndexViewModel { Expenses = SetViewModelsService.SetExpenseViewModels(expenses) }; return(vm); }
public IActionResult Edit(int id) { var objcategory = _unitofWork.expenses.Get(id); if (objcategory == null) { return(NotFound()); } var model = new ExpenseIndexViewModel() { id = objcategory.id, Name = objcategory.Name, isactive = objcategory.isactive, isdeleted = objcategory.isdeleted }; return(View(model)); }
public async Task <IActionResult> Edit(ExpenseIndexViewModel model) { if (ModelState.IsValid) { var storeobj = _unitofWork.expenses.Get(model.id); if (storeobj == null) { TempData["error"] = "Record Not Found"; return(NotFound()); } storeobj.id = model.id; storeobj.Name = model.Name; _unitofWork.expenses.Update(storeobj); _unitofWork.Save(); TempData["success"] = "Record Update successfully"; return(RedirectToAction(nameof(Index))); } else { return(View()); } }
public ActionResult ExpensesIndex(DateTime?DateFrom, DateTime?DateTo) { int TotalExpense = 0; int AllExpense = 0; ExpenseIndexViewModel expIndex = new ExpenseIndexViewModel(); List <ExpenseIndexViewModel> expList = new List <ExpenseIndexViewModel>(); Payment payment = new Payment(); Cement cement = new Cement(); if (DateFrom != null && DateTo != null) { foreach (Expense exp in db.Expenses.Include(t => t.Payment).Where(t => t.Payment.DateofCheque > DateFrom && t.Payment.DateofCheque < DateTo)) { expIndex = new ExpenseIndexViewModel(); cement = db.Cements.Where(t => t.TransactionID == exp.Payment.TransactionID).FirstOrDefault(); expIndex.SONumber = cement.SOnumber; expIndex.DateProcessed = cement.CurrentDate; expIndex.Stats = cement.Stats; if (cement.RenewalPayment != 0) { expIndex.TotalExpense += cement.RenewalPayment; } foreach (Expense addExpense in db.Expenses.Where(t => t.PaymentID == exp.PaymentID)) { TotalExpense += addExpense.Total; expIndex.SONumber = db.Cements.Where(t => t.TransactionID == addExpense.Payment.TransactionID).LastOrDefault().SOnumber; } expIndex.TotalExpense = TotalExpense; TotalExpense = 0; expList.Add(expIndex); AllExpense += exp.Total; } } else { foreach (Expense exp in db.Expenses.Include(t => t.Payment)) { expIndex = new ExpenseIndexViewModel(); cement = db.Cements.Where(t => t.TransactionID == exp.Payment.TransactionID).OrderByDescending(t => t.DateCreation).First(); expIndex.SONumber = cement.SOnumber; expIndex.DateProcessed = cement.CurrentDate; expIndex.Stats = cement.Stats; if (cement.RenewalPayment != 0) { expIndex.TotalExpense += cement.RenewalPayment; } foreach (Expense addExpense in db.Expenses.Where(t => t.PaymentID == exp.PaymentID)) { TotalExpense += addExpense.Total; } expIndex.TotalExpense = TotalExpense; TotalExpense = 0; expList.Add(expIndex); AllExpense += exp.Total; } } ViewBag.AllExpense = AllExpense; return(View(expList.ToList().GroupBy(l => l.SONumber).Select(group => group.Last()))); }
public IActionResult Create() { var model = new ExpenseIndexViewModel(); return(View(model)); }
public ExpenseIndexViewModel MapExpenseIndexViewModel(string username) { var expenses = FinancialPlannerRepository.GetExpenses() .Where(m => m.Username == username); var vm = new ExpenseIndexViewModel { Expenses = SetViewModelsService.SetExpenseViewModels(expenses) }; return vm; }