public ActionResult DeleteConfirmed(int id) { p_customer p_customer = db.p_customer.Find(id); db.p_customer.Remove(p_customer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "cid,fname,lname,telephone,streetNo,street_name,apt_no,zipcode")] p_customer p_customer) { if (ModelState.IsValid) { db.Entry(p_customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(p_customer)); }
public p_customer FindCustomerById(String id) { p_customer cus = null; try { cus = context.p_customer.FirstOrDefault(e => e.customer_id == id); } catch (Exception e) { } return cus; }
public ActionResult Create([Bind(Include = "cid,fname,lname,telephone,streetNo,street_name,apt_no,zipcode")] p_customer p_customer) { if (ModelState.IsValid && !db.p_customer.Where(x => x.fname == p_customer.fname && x.lname == p_customer.lname).Any()) { db.p_customer.Add(p_customer); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ErrorMessage = "Customer already Exists"; return(View(p_customer)); }
public p_customer AddNewCustomer(p_customer customer) { p_customer cus = null; try { cus = context.p_customer.Add(customer); return cus; } catch (Exception e) { } return cus; }
public p_customer RemoveCustomerById(String id) { p_customer cus = null; try { cus = FindCustomerById(id); context.p_customer.Remove(cus); context.SaveChanges(); } catch (Exception e) { } return cus; }
// GET: p_customer/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } p_customer p_customer = db.p_customer.Find(id); if (p_customer == null) { return(HttpNotFound()); } return(View(p_customer)); }
public p_customer EditCustomerById(p_customer obj) { p_customer cus = null; try { cus = FindCustomerById(obj.customer_id); if (cus != null) { cus.customer_id = obj.customer_id; cus.address = obj.address; cus.company = obj.company; cus.date_of_birth = obj.date_of_birth; cus.email = obj.email; cus.identity_no = obj.identity_no; cus.name = obj.name; cus.password = obj.password; context.SaveChanges(); return cus; } } catch (Exception e) { } return cus; }