public async Task <ActionResult> Create([Bind(Include = "t_id,nameOnCard,cardNumber,unit_price,quantity,total_price,exp_Date,createdOn,createdBy,c_id,s_id,user_id")] transaction transaction) { string cardStart = transaction.cardNumber.Substring(0, 2); creditcard_type cctype = db.creditcard_type.Where(x => x.starts_with == cardStart && x.length == transaction.cardNumber.Length).FirstOrDefault(); if (cctype == null) { ViewBag.errormessage = "Invalid Card Number"; return(View("Create", transaction)); } transaction.c_id = cctype.c_id; transaction.total_price = transaction.quantity * transaction.unit_price; transaction.createdOn = DateTime.Now; transaction.createdBy = System.Security.Principal.WindowsIdentity.GetCurrent().Name; transaction.user_id = Convert.ToInt32(Session["user_id"].ToString()); if (ModelState.IsValid) { db.transactions.Add(transaction); int transactionId = await db.SaveChangesAsync(); return(RedirectToAction("Details", new { id = transaction.t_id })); } return(View(transaction)); }
public async Task <ActionResult> DeleteConfirmed(int id) { creditcard_type creditcard_type = await db.creditcard_type.FindAsync(id); db.creditcard_type.Remove(creditcard_type); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "c_id,name,starts_with,length")] creditcard_type creditcard_type) { if (ModelState.IsValid) { db.Entry(creditcard_type).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(creditcard_type)); }
public async Task <ActionResult> Create([Bind(Include = "c_id,name,starts_with,length")] creditcard_type creditcard_type) { if (ModelState.IsValid) { db.creditcard_type.Add(creditcard_type); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(creditcard_type)); }
// GET: creditcard_type/Edit/5 /// <summary> /// Editing of Existing Creditcard Details by Admin /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } creditcard_type creditcard_type = await db.creditcard_type.FindAsync(id); if (creditcard_type == null) { return(HttpNotFound()); } return(View(creditcard_type)); }