示例#1
0
        //
        // GET+POST: /Backend/EditUser?id={id}
        public ActionResult EditUser()
        {
            if (Request.Params.AllKeys.Contains("id"))
            {
                long id = 0;
                try
                {
                    id = long.Parse(Request.Params["id"]);
                }
                catch { }

                Form_User_Add form = new Form_User_Add();
                form.setRoles(this._app.roles().getAll());

                user edited = this._app.users().getById(id);

                if (edited != null)
                {
                    form.setEditData(edited);

                    if (Request.HttpMethod.ToLower() == form.getMethod().ToString())
                    {
                        if (form.isValid(Request.Form))
                        {
                            if (this._app.users().save(form, edited))
                            {
                                _messages.addMessage("The user has been successfully saved");
                                return Redirect("/backend/ListUsers");
                            }
                            else
                            {
                                _messages.addError("The user hasn't been saved");
                            }
                        }
                    }

                    ViewData["form"] = form.render();

                    return View();
                }
            }
            _messages.addError("Undefined or wrong parameter ID");
            return RedirectToAction("listUsers", "backend");
        }
示例#2
0
        //
        // GET+POST: /Backend/AddUser
        public ActionResult AddUser()
        {
            Form_User_Add form = new Form_User_Add();
            form.setRoles(this._app.roles().get());

            if (Request.HttpMethod.ToLower() == form.getMethod().ToString())
            {
                if (form.isValid(Request.Form))
                {
                    if (this._app.users().add(form))
                    {
                        _messages.addMessage("The user has been successfully added");
                        return Redirect("/backend/ListUsers");
                    }
                }
            }

            ViewData["form"] = form.render();

            return View();
        }