Ejemplo n.º 1
0
        public ActionResult ListPartial(int page = 1, string sortCol = "RoleID", string sortType = "asc")
        {
            string err;

            try {
                var result = MBFDB.GetRolePageList <RoleViewModel>(out err, page, MBFDB.PageSize, sortCol, sortType);
                ViewBag.Page     = page;
                ViewBag.SortCol  = sortCol;
                ViewBag.SortType = sortType;
                //
                Session["PageInfo"] = new PageInfoModel(page, sortCol, sortType);
                if (string.IsNullOrEmpty(err))
                {
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    return(PartialView("ListPartial", result));
                }
                else
                {
                    LOG.Trace(ERRHD.BuildTraceMessage(ExceptionHandle.MBF_ERROR.ERR_DB_ACCESS, "MBFDB.GetRolePageList"));
                    return(new HttpStatusCodeResult(500, ERRHD.BuildUserMsg(ExceptionHandle.MBF_ERROR.ERR_DB_ACCESS)));
                }
            }
            catch (Exception ex) {
                LOG.Fatal(ERRHD.BuildExceptionMessage(ex));
                return(new HttpStatusCodeResult(500, "exception error."));
            }
        }
Ejemplo n.º 2
0
        // GET: Role/Edit/5
        public ActionResult Edit(long id)
        {
            string err;

            try {
                var model = MBFDB.GetRole(out err, id);
                if (string.IsNullOrEmpty(err))
                {
                    return(PartialView(model));
                }
                else
                {
                    LOG.Trace(ERRHD.BuildTraceMessage(ExceptionHandle.MBF_ERROR.ERR_DB_ACCESS, "MBFDB.GetRole"));
                    return(new HttpStatusCodeResult(500, ERRHD.BuildUserMsg(ExceptionHandle.MBF_ERROR.ERR_DB_ACCESS)));
                }
            }
            catch (Exception ex) {
                LOG.Fatal(ERRHD.BuildExceptionMessage(ex));
                return(new HttpStatusCodeResult(500, "exception error."));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(string roleID, string roleName)
        {
            int    ret = 0;
            string err = "";

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Create"));
            }

            if (string.IsNullOrEmpty(roleID) || string.IsNullOrEmpty(roleName))
            {
                LOG.Trace(ERRHD.BuildTraceMessage(ExceptionHandle.MBF_ERROR.ERR_DATA_EMPTY));
                return(new HttpStatusCodeResult(500, ERRHD.BuildUserMsg(ExceptionHandle.MBF_ERROR.ERR_DATA_EMPTY)));
            }

            try {
                var model = new RoleViewModel();
                model.RoleID   = roleID;
                model.RoleName = roleName;
                ret            = MBFDB.InsertRole(out err, model);
                if (ret > 0)
                {
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    var pageInfo = (PageInfoModel)Session["PageInfo"];
                    return(RedirectToAction("ListPartial", new { page = pageInfo.Page, SortCol = pageInfo.SortCol, SortType = pageInfo.SortType }));
                }
                else
                {
                    LOG.Trace(ERRHD.BuildTraceMessage(ExceptionHandle.MBF_ERROR.ERR_DB_INSERT, "MBFDB.InsertRole"));
                    return(new HttpStatusCodeResult(500, ERRHD.BuildUserMsg(ExceptionHandle.MBF_ERROR.ERR_DB_INSERT)));
                }
            }
            catch (Exception ex) {
                LOG.Fatal(ERRHD.BuildExceptionMessage(ex));
                return(new HttpStatusCodeResult(500, "exception error."));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            string err;

            try {
                int ret = MBFDB.DeleteRole(out err, id);
                if (ret > 0)
                {
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    var pageInfo = (PageInfoModel)Session["PageInfo"];
                    return(RedirectToAction("ListPartial", new { page = pageInfo.Page, SortCol = pageInfo.SortCol, SortType = pageInfo.SortType }));
                }
                else
                {
                    LOG.Trace(ERRHD.BuildTraceMessage(ExceptionHandle.MBF_ERROR.ERR_DB_DELETE, "MBFDB.DeleteRole"));
                    return(new HttpStatusCodeResult(500, ERRHD.BuildUserMsg(ExceptionHandle.MBF_ERROR.ERR_DB_DELETE)));
                }
            }
            catch (Exception ex) {
                LOG.Fatal(ERRHD.BuildExceptionMessage(ex));
                return(new HttpStatusCodeResult(500, "exception error."));
            }
        }