예제 #1
0
        public int DeletePermission(string code)
        {
            using (Entities db = new Entities())
            {
                base_permissions model = db.base_permissions.Find(code);

                if (model != null)
                {
                    List <base_permissionmenus> pmList = db.base_permissionmenus.Where(t => t.permissioncode == code).ToList();

                    if (pmList.Count > 0)
                    {
                        foreach (base_permissionmenus item in pmList)
                        {
                            db.base_permissionmenus.Remove(item);
                        }
                    }

                    List <base_rolepermissions> rmList = db.base_rolepermissions.Where(t => t.permissioncode == code).ToList();

                    if (rmList.Count > 0)
                    {
                        foreach (base_rolepermissions item in rmList)
                        {
                            db.base_rolepermissions.Remove(item);
                        }
                    }

                    db.base_permissions.Remove(model);
                }

                return(db.SaveChanges());
            }
        }
예제 #2
0
        public int AddPermission(Permission model)
        {
            using (Entities db = new Entities())
            {
                base_permissions newModel = new base_permissions()
                {
                    code       = model.Code,
                    name       = model.Name,
                    parentcode = model.ParentCode,
                    path       = model.Path,
                    comment    = model.Comment,
                    seqno      = model.SeqNo
                };
                db.base_permissions.Add(newModel);

                return(db.SaveChanges());
            }
        }
예제 #3
0
        public int EditPermission(Permission model)
        {
            using (Entities db = new Entities())
            {
                base_permissions newModel = db.base_permissions.Find(model.Code);

                if (newModel != null)
                {
                    newModel.code    = model.Code;
                    newModel.name    = model.Name;
                    newModel.comment = model.Comment;
                    newModel.seqno   = model.SeqNo;

                    return(db.SaveChanges());
                }
            }

            return(0);
        }