public async Task <ActionResult> DeleteConfirmed(int id) { TypeLoan typeLoan = await db.TypeLoans.FindAsync(id); db.TypeLoans.Remove(typeLoan); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "TypeLoanId,Description")] TypeLoan typeLoan) { if (ModelState.IsValid) { db.Entry(typeLoan).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(typeLoan)); }
public async Task <ActionResult> Create([Bind(Include = "TypeLoanId,Description")] TypeLoan typeLoan) { if (ModelState.IsValid) { db.TypeLoans.Add(typeLoan); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(typeLoan)); }
// GET: TypeLoans/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TypeLoan typeLoan = await db.TypeLoans.FindAsync(id); if (typeLoan == null) { return(HttpNotFound()); } return(View(typeLoan)); }
public static int GetTypeLoan(string description, LocalDataContext db) { var typeLoan = db.TypeLoans.Where(s => s.Description == description).FirstOrDefault(); if (typeLoan == null) { typeLoan = new TypeLoan { Description = description, }; db.TypeLoans.Add(typeLoan); db.SaveChanges(); } return(typeLoan.TypeLoanId); }