public Task <object> InsertAsync(RoleInPagesModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("Role ArgumentNullException Insert Async");
            }

            RoleInPages dto = AutoMapperGenericHelper <RoleInPagesModel, RoleInPages> .Convert(model);

            var id = _roleInPagesRepository.Insert(dto);

            return(Task.FromResult <object>(id));
        }
        public Task UpdateAsync(RoleInPagesModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("RoleInPages ArgumentNullException UpdateAsync");
            }


            RoleInPages dto = AutoMapperGenericHelper <RoleInPagesModel, RoleInPages> .Convert(model);

            _roleInPagesRepository.Update(dto);

            return(Task.FromResult <object>(null));
        }
Пример #3
0
        public void init_auth_data()
        {
            #region Init Client
            _uow.BeginTransaction();
            Clients client = new Clients()
            {
                ClientId             = "bilisimHR.WebApp",
                Secret               = Utility.GetHash("bilisimHR@WebApp"),
                Name                 = "bilisimHR Web Portali",
                ApplicationType      = ApplicationTypes.WebDevelopment,
                Active               = true,
                RefreshTokenLifeTime = 7200,
                AllowedOrigin        = "*"
            };
            int clientId = (int)_uow.Session.Save(client);
            _uow.Commit();
            #endregion

            #region Init User
            _uow.BeginTransaction();
            string saltedPassword = string.Empty;
            string salt           = string.Empty;

            Utility.SaltPassword("123456", out salt, out saltedPassword);
            int userId = (int)_uow.Session.Save(new Users
            {
                UserName             = "******",
                PasswordHash         = saltedPassword,
                Salt                 = salt,
                EmailConfirmed       = false,
                PhoneNumberConfirmed = false,
                LockoutEnabled       = false,
                AccessFailedCount    = 0
            });
            _uow.Commit();
            #endregion

            #region Init Role
            _uow.BeginTransaction();
            int roleId = (int)_uow.Session.Save(new Roles {
                Name = "Yetkilendirme(Tam)"
            });
            _uow.Commit();
            #endregion

            #region Init Page
            _uow.BeginTransaction();
            int pageId = (int)_uow.Session.Save(new Pages {
                Name = "Administration"
            });
            _uow.Commit();
            #endregion

            #region InitControllerActions
            _uow.BeginTransaction();
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "GetAll", Description = "Get All Clients", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "Get", Description = "Get Client By ID", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "GetByClientId", Description = "Get Client By ClientId", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "Post", Description = "Create New Client", OperationType = (OperationType)0
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "Patch", Description = "Update Client", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "ClientsController", Action = "Delete", Description = "Delete Client By ID", OperationType = (OperationType)3
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "GetAll", Description = "Get All Pages", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "Get", Description = "Get Page By ID", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "Post", Description = "Create New Page", OperationType = (OperationType)0
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "Patch", Description = "Update Page", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "Delete", Description = "Delete Page By ID", OperationType = (OperationType)3
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "InsertControllerAction", Description = "Insert ControllerAction(s) To Page", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "PagesController", Action = "DeleteControllerAction", Description = "Delete ControllerAction(s) From Page", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RoleInPagesController", Action = "GetAll", Description = "Get All RoleInPages", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RoleInPagesController", Action = "Get", Description = "Get RoleInPages By ID", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RoleInPagesController", Action = "Post", Description = "Create New RoleInPages", OperationType = (OperationType)0
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RoleInPagesController", Action = "Patch", Description = "Update RoleInPages", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RoleInPagesController", Action = "Delete", Description = "Delete RoleInPages By ID", OperationType = (OperationType)3
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "GetAll", Description = "Get All Roles", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "Get", Description = "Get Role By ID", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "Post", Description = "Create New Role", OperationType = (OperationType)0
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "Patch", Description = "Update Role", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "Delete", Description = "Delete Role By ID", OperationType = (OperationType)3
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "InsertUsers", Description = "Insert User(s) To Role", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "DeleteRoles", Description = "Delete User(s) From Role", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "InsertPages", Description = "Insert Pages(s) To Role", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "RolesController", Action = "DeletePages", Description = "Delete Pages(s) From Role", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "GetAll", Description = "Get All Users", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "GetById", Description = "Get User By ID", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "GetByEmail", Description = "Get User By Email", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "GetByUserName", Description = "Get User By UserName", OperationType = (OperationType)1
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "Post", Description = "Create User", OperationType = (OperationType)0
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "Patch", Description = "Update User", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "Delete", Description = "Delete User By ID", OperationType = (OperationType)3
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "InsertRoles", Description = "Insert Role(s) To User", OperationType = (OperationType)2
            });
            _uow.Session.Save(new ControllerActions {
                Controller = "UsersController", Action = "DeleteRoles", Description = "Delete Role(s) From User", OperationType = (OperationType)2
            });
            _uow.Commit();
            #endregion

            #region Set Page Actions
            _uow.BeginTransaction();
            Pages page = _uow.Session.Get <Pages>(pageId);
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(1));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(2));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(3));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(4));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(5));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(6));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(7));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(8));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(9));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(10));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(11));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(12));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(13));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(14));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(15));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(16));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(17));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(18));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(19));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(20));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(21));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(22));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(23));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(24));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(25));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(26));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(27));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(28));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(29));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(30));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(31));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(32));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(33));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(34));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(35));
            page.ControllerActions.Add(_uow.Session.Get <ControllerActions>(36));
            _uow.Session.Save(page);
            _uow.Commit();
            #endregion

            #region Set Role Pages
            _uow.BeginTransaction();
            RoleInPages roleInPages = new RoleInPages()
            {
                Role   = _uow.Session.Get <Roles>(roleId),
                Page   = _uow.Session.Get <Pages>(pageId),
                Create = false,
                Read   = false,
                Update = true,
                Delete = true
            };
            _uow.Session.Save(roleInPages);
            _uow.Commit();
            #endregion

            #region Set User Roles
            _uow.BeginTransaction();
            Users user = _uow.Session.Get <Users>(userId);
            user.Roles.Add(_uow.Session.Get <Roles>(roleId));
            _uow.Session.Save(user);
            _uow.Commit();
            #endregion
        }