Esempio n. 1
0
        /// <summary>
        /// 保存菜单和行为的关联
        /// </summary>
        /// <param name="menuid"></param>
        /// <param name="actionids"></param>
        /// <returns></returns>
        public bool SaveMenuAction(string menuid, List <string> actionids)
        {
            dapper_testEntities db = _repository.GetDb();

            using (var scope = db.Database.BeginTransaction())
            {
                try
                {
                    string sql = string.Format("delete from rel_menuactions where menuid='{0}'", menuid);
                    db.Database.ExecuteSqlCommand(sql);
                    if (actionids != null && actionids.Count > 0)
                    {
                        foreach (var actid in actionids)
                        {
                            rel_menuactions one = new rel_menuactions()
                            {
                                menuid   = menuid,
                                actionid = actid,
                                isuse    = true
                            };
                            db.Set <rel_menuactions>().Add(one);
                        }
                    }
                    db.SaveChanges();
                    scope.Commit();//正常完成就可以提交
                    return(true);
                }
                catch (Exception ex)
                {
                    scope.Rollback();//发生异常就回滚
                    return(false);
                }
            }
        }
Esempio n. 2
0
 public bool Delete(rel_menuactions p)
 {
     return(_repository.Delete(p));
 }
Esempio n. 3
0
 public bool Update(rel_menuactions p)
 {
     return(_repository.Update(p));
 }
Esempio n. 4
0
 /// <summary>
 /// 修改指定的字段
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="fileds"></param>
 /// <returns></returns>
 public bool UpdateSubFields(rel_menuactions entity, List <string> fileds)
 {
     return(_repository.UpdateSubFields(entity, fileds));
 }
Esempio n. 5
0
 public bool Insert(rel_menuactions p)
 {
     return(_repository.Insert(p));
 }