public ActionResult DeleteConfirmed(int IncomeID) { income income = IncomeRepository.GetIncomeByID(IncomeID); IncomeRepository.DeleteRecord(income); return(RedirectToAction("Create")); }
public ActionResult Edit(income income) { try { subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID); if (income.bankAccountID == 0) { income.bankAccountID = subCat.bankAccountID; } if (income.Comment == null) { income.Comment = ""; } income.Title = subCat.SubCategoryName; income.bankAccountID = subCat.bankAccountID; if (ModelState.IsValid) { db.Entry(income).State = EntityState.Modified; db.SaveChanges(); TempData["Message2"] = "Record update successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error editing record."; } GetData(); return(PartialView(income)); }
public ActionResult Edit(int IncomeID) { GetData(); income income = db.incomes.Find(IncomeID); return(PartialView(income)); }
public ActionResult Create(income income) { try { subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID); if (income.bankAccountID == 0) { income.bankAccountID = subCat.bankAccountID; } if (income.Title == null) { income.Title = subCat.SubCategoryName; } if (income.Comment == null) { income.Comment = ""; } if (ModelState.IsValid) { db.incomes.Add(income); db.SaveChanges(); IncomeRepository.AddRecord(income); TempData["Message2"] = "Income added successfully."; return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding income"; } GetData(); return(PartialView(income)); }
public ActionResult Delete(int IncomeID) { ViewBag.IncomeID = IncomeID; income income = IncomeRepository.GetIncomeByID(IncomeID); ViewBag.TotalAmount = income.CashAmount + income.CheckAmount + income.CoinAmount; return(PartialView(income)); }
//[Route("api/expense/add")] public IHttpActionResult AddIncome([FromBody] income inc) { if (ModelState.IsValid) { dbContext.incomes.Add(inc); dbContext.SaveChanges(); return(Ok(inc)); } else { return(BadRequest()); } }
public ActionResult incomeDelete(String id) { if (id != "") { income income = new income(); income.id = int.Parse(id); db.deleteIncome(income); return(Json("success", JsonRequestBehavior.AllowGet)); } else { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult InsertData(String date, String category, String cash, String pos, String amount) { if (date != "" && category != "" && cash != "" && pos != "" && amount != "") { income income = new income(); income.date = date; income.category = category; income.cash = Double.Parse(cash); income.pos = Double.Parse(pos); income.total = Double.Parse(amount); db.incomeInsert(income); return(Json("success", JsonRequestBehavior.AllowGet)); } else { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public income GetIncomeByID(int incomeID) { record = myRecords.FirstOrDefault(e => e.incomeID == incomeID); return(record); }
public void AddRecord(income Record) { myRecords.Add(record); }
public void DeleteRecord(income record) { myRecords.Remove(record); context.incomes.Remove(record); context.SaveChanges(); }
public int GetLastIncomeRecordID() { record = myRecords.OrderByDescending(e => e.incomeID).Take(1).SingleOrDefault(); return(record.incomeID); }