コード例 #1
0
ファイル: WWIDal.cs プロジェクト: waltonsoftware/WWI
        public int UpdateRole(AspNetRolesModel model)
        {
            SQLData             db    = new SQLData();
            string              sql   = "UPDATE dbo.AspNetRoles SET Name=@Name, AccessLevel=@AccessLevel WHERE Id=@Id";
            List <SqlParameter> parms = new List <SqlParameter>();
            int _ret = 0;

            try
            {
                parms.Add(new SqlParameter("@Id", model.Id));
                parms.Add(new SqlParameter("@Name", model.Name));
                db.Open(ConfigurationManager.ConnectionStrings["WWI"].ConnectionString);
                _ret = db.ExecuteNonQuery(sql, parms);
            }
            catch (Exception ex)
            {
                Logger.LogError("UpdateRole Exception: ", ex);
            }
            finally
            {
                db.Close();
            }

            return(_ret);
        }
コード例 #2
0
ファイル: WWIDal.cs プロジェクト: waltonsoftware/WWI
        public AspNetRolesModel GetRole(string id)
        {
            SQLData             db    = new SQLData();
            string              sql   = "SELECT * FROM dbo.AspNetRoles WHERE Id=@Id";
            List <SqlParameter> parms = new List <SqlParameter>();
            AspNetRolesModel    model = new AspNetRolesModel();

            try
            {
                db.Open(ConfigurationManager.ConnectionStrings["WWI"].ConnectionString);
                parms.Add(new SqlParameter("@Id", id));
                DataTable dt  = db.Execute(sql, parms);
                DataRow   row = dt.Rows[0];

                if (!row["Id"].ToString().Equals(string.Empty))
                {
                    model.Id = row["Id"].ToString();
                }

                if (!row["Name"].ToString().Equals(string.Empty))
                {
                    model.Name = row["Name"].ToString();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("GetRole exception: ", ex);
            }
            finally
            {
                db.Close();
            }

            return(model);
        }
コード例 #3
0
ファイル: WWIDal.cs プロジェクト: waltonsoftware/WWI
        public AspNetRolesModel AddRole(string name)
        {
            SQLData             db    = new SQLData();
            string              sql   = "INSERT INTO dbo.AspNetRoles (Id, Name, AccessLevel) VALUES(@Id, @Name, @AccessLevel)";
            List <SqlParameter> parms = new List <SqlParameter>();
            AspNetRolesModel    model = new AspNetRolesModel();

            try
            {
                model.Id   = Guid.NewGuid().ToString();
                model.Name = name;
                parms.Add(new SqlParameter("@Id", model.Id));
                parms.Add(new SqlParameter("@Name", model.Name));
                db.Open(ConfigurationManager.ConnectionStrings["WWI"].ConnectionString);
                db.ExecuteNonQuery(sql, parms);
            }
            catch (Exception ex)
            {
                Logger.LogError("AddRole Exception: ", ex);
            }
            finally
            {
                db.Close();
            }

            return(model);
        }
コード例 #4
0
        private AspNetRolesModel Mapping(AspNetRoles rol)
        {
            AspNetRolesModel model = new AspNetRolesModel();

            model.Description = rol.Description;
            model.Estatus     = rol.Estatus;
            model.Id          = rol.Id;
            model.Name        = rol.Name;

            return(model);
        }
コード例 #5
0
        public ActionResult EditRole(AspNetRolesModel model)
        {
            try
            {
                WWIDal dal             = new WWIDal();
                int    recordsEffected = dal.UpdateRole(model);
            }
            catch (Exception ex)
            {
                Logger.LogError("UpdateRole Post exception: ", ex);
            }

            return(RedirectToAction("Roles"));
        }
コード例 #6
0
        public ActionResult AddRole(AspNetRolesModel model)
        {
            try
            {
                WWIDal dal = new WWIDal();
                model = dal.AddRole(model.Name);
            }
            catch (Exception ex)
            {
                Logger.LogError("AddRole Post Exception: ", ex);
            }

            return(RedirectToAction("Roles"));
        }