public ActionResult PlanDetail(PlanDetailModel model) { var id = Request.Params["customerId"].ToString(); TB_PLAN_DETAIL detail = new TB_PLAN_DETAIL(); detail.N_AMOUNT = model.amount; detail.N_CUSTOMER_ID = int.Parse(id); detail.N_PLAN_ID = model.planId; detail.S_DESCRIPTION = model.description; detail.S_DETAIL = model.detail; detail.D_EXPRIRE = model.exprireDate; var modelDB = new CustomerDBModel(); var modelDB2 = new PlanDBModel(); modelDB.createPlanDetail(detail); var plan = modelDB2.getPlanById(model.planId); Random rnd = new Random(); int ramdom01 = rnd.Next(10000, 99999); int ramdom02 = rnd.Next(10000, 99999); TB_CUSTOMER customer = new TB_CUSTOMER(); customer.N_ID = int.Parse(id); customer.S_CODE = plan.S_NAME[0].ToString() + ramdom01.ToString() + ramdom02.ToString(); modelDB.updateCodeById(customer); return(RedirectToAction("List")); }
// GET: Admin/Store/Edit/5 public ActionResult Edit(int n_id) { var modelDB = new PlanDBModel(); var model = new PlanModel(); var result = modelDB.getPlanById(n_id); model.id = result.N_ID; model.name = result.S_NAME; model.type = result.S_TYPE; model.detail = result.S_DETAIL; model.description = result.S_DESCRIPTION; model.status = result.S_STATUS; model.createdDate = result.D_CREATED; return(View(model)); }
// GET: Detail public ActionResult Index(int id, string type) { if (id < 1) { return(RedirectToAction("Index", "Home")); } else { InfoSession modelSession = new InfoSession(); modelSession = SessionHelper.GetInfoSession(); Session["infoSession"] = modelSession; DetailModel detailModel = new DetailModel(); if (type.Equals("PLAN")) { var planDBModel = new PlanDBModel(); var model = planDBModel.getPlanById(id); detailModel.id = model.N_ID; detailModel.name = model.S_NAME; detailModel.type = type; detailModel.detail = model.S_DETAIL; detailModel.description = model.S_DESCRIPTION; detailModel.total = 1; } else { var productDBModel = new ProductDBModel(); var model = productDBModel.getProductById(id); detailModel.id = model.N_ID; detailModel.name = model.S_NAME; detailModel.type = type; detailModel.detail = model.S_DETAIL; detailModel.description = model.S_DESCRIPTION; detailModel.price = model.N_PRICE; detailModel.total = 1; } return(View(detailModel)); } }