コード例 #1
0
        public void SaveOrUpdate(string startupUrl, string roleStartupType, long[] roles)
        {
            using (var txn = _entityRepository.BeginTransaction())
            {
                foreach (var item in roles)
                {
                    var startup         = new NccStartup();
                    var startupType     = (StartupType)Enum.Parse(typeof(StartupType), roleStartupType);
                    var existingStartup = Get(item, StartupFor.Role);
                    var permission      = _nccPermissionRepository.Get(item);

                    if (existingStartup == null)
                    {
                        startup.Permission  = permission;
                        startup.StartupFor  = StartupFor.Role;
                        startup.StartupType = startupType;
                        startup.StartupUrl  = startupUrl;
                        _entityRepository.Add(startup);
                    }
                    else
                    {
                        existingStartup.Permission  = permission;
                        existingStartup.StartupFor  = StartupFor.Role;
                        existingStartup.StartupType = startupType;
                        existingStartup.StartupUrl  = startupUrl;
                        _entityRepository.Edit(existingStartup);
                    }
                }
                _entityRepository.SaveChange();
                txn.Commit();
            }
        }
コード例 #2
0
 public NccStartup Save(NccStartup entity)
 {
     _entityRepository.Add(entity);
     _entityRepository.SaveChange();
     return(entity);
 }