// // GET: /User/Edit/5 public ActionResult Edit(String id) { DAL.z_user dal_z_user = new DAL.z_user(); Models.z_user model_z_user = dal_z_user.GetModel(new Guid(id)); DAL.z_parameter dal_z_parameter = new DAL.z_parameter(); DAL.z_role dal_z_role = new DAL.z_role(); ViewBag.role_list = dal_z_role.GetModelList(); ViewBag.role_list_user = dal_z_role.GetModelList(new Guid(id)); return View(model_z_user); }
public ActionResult Edit(String id, FormCollection collection) { DAL.z_user dal_z_user = new DAL.z_user(); Models.z_user model_z_user = dal_z_user.GetModel(new Guid(id)); DAL.z_r_user_role dal_z_r_user_role = new DAL.z_r_user_role(); DAL.z_parameter dal_z_parameter = new DAL.z_parameter(); DAL.z_role dal_z_role = new DAL.z_role(); ViewBag.role_list = dal_z_role.GetModelList(); ViewBag.role_list_user = dal_z_role.GetModelList(new Guid(id)); try { // TODO: Add insert logic here string USER_CD = collection["USER_CD"].Trim(); string PASSWORD = collection["PASSWORD"].Trim(); string PASSWORD_RE = collection["PASSWORD_RE"].Trim(); string LAST_NAME = collection["LAST_NAME"].Trim(); string EMAIL = collection["EMAIL"].Trim(); string MOBILE_NUM = collection["MOBILE_NUM"].Trim(); string DESCRIPTION = collection["DESCRIPTION"].Trim(); string ROLE = collection["ROLE"]; if (USER_CD == "" || LAST_NAME == "" || ROLE == null) { ViewBag.message = "Create Failed, field with red start can't be blank"; return View(model_z_user); } if (PASSWORD != "" && PASSWORD != PASSWORD_RE) { ViewBag.message = "Create Failed, password does not match"; return View(model_z_user); } if (dal_z_user.isCdDuplicate(USER_CD, model_z_user.ID.ToString())) { ViewBag.message = "Create Failed, account is already exist"; return View(model_z_user); } model_z_user.USER_CD = USER_CD; if (PASSWORD != "") { model_z_user.PASSWORD = Common.Common.MD5(PASSWORD); } model_z_user.LAST_NAME = LAST_NAME; model_z_user.EMAIL = EMAIL; model_z_user.MOBILE_NUM = MOBILE_NUM; model_z_user.DESCRIPTION = DESCRIPTION; model_z_user.UPDATE_DATETIME = DateTime.Now; dal_z_user.Update(model_z_user); dal_z_r_user_role.DeleteRoleByUserID(model_z_user.ID.ToString()); dal_z_r_user_role.Add(model_z_user.ID.ToString(), ROLE); return RedirectToAction("Index", new { message = HttpUtility.UrlEncode("Edit Succeed") }); } catch { ViewBag.message = "Edit Failed"; return View(model_z_user); } }
// // GET: /User/Details/5 public ActionResult Details(String id) { try { DAL.z_user dal_z_user = new DAL.z_user(); Models.z_user model_z_user = dal_z_user.GetModel(new Guid(id)); DAL.z_role dal_z_role = new DAL.z_role(); List<Models.z_role> z_role_list = dal_z_role.GetModelList(new Guid(id)); ViewBag.z_role_list = z_role_list; return View(model_z_user); } catch { ViewBag.message = "Item does not exist"; return View(); } }