Пример #1
0
 public async Task Create(AccountRegisterLoginViewModel model)
 {
     var accountDto = _mapper.Map <AccountRegisterLoginDto>(model);
     await _authorizeRepository.CreateAsync(accountDto);
 }
Пример #2
0
        public async Task <bool> SavePermission(string objectId, string currentUserId, int category, List <AuthorizeIdType> modules, List <AuthorizeIdType> buttons, List <AuthorizeIdType> columns, List <AuthorizeIdType> routes, string dataBaseName)
        {
            var delAuthorizes = await authorizeRepo.GetListAsync(a => a.ObjectId == objectId, dataBaseName);

            await authorizeRepo.DeleteAsync(delAuthorizes, dataBaseName);

            var addAuthorizes = new List <Authorize>();

            modules.ForEach(module =>
            {
                var entity = new Authorize()
                {
                    AuthorizeId  = Guid.NewGuid().ToString(),
                    Category     = category,
                    ItemType     = 1,
                    ItemId       = module.Id,
                    ObjectId     = objectId,
                    CreateDate   = DateTime.Now,
                    CreateUserId = currentUserId,
                    IsHalf       = module.IsHalf
                };
                addAuthorizes.Add(entity);
            });
            buttons.ForEach(button =>
            {
                var entity = new Authorize()
                {
                    AuthorizeId  = Guid.NewGuid().ToString(),
                    Category     = category,
                    ItemType     = 2,
                    ItemId       = button.Id,
                    ObjectId     = objectId,
                    CreateDate   = DateTime.Now,
                    CreateUserId = currentUserId,
                    IsHalf       = button.IsHalf
                };
                addAuthorizes.Add(entity);
            });
            columns.ForEach(column =>
            {
                var entity = new Authorize()
                {
                    AuthorizeId  = Guid.NewGuid().ToString(),
                    Category     = category,
                    ItemType     = 3,
                    ItemId       = column.Id,
                    ObjectId     = objectId,
                    CreateDate   = DateTime.Now,
                    CreateUserId = currentUserId,
                    IsHalf       = column.IsHalf
                };
                addAuthorizes.Add(entity);
            });
            routes.ForEach(route =>
            {
                var entity = new Authorize()
                {
                    AuthorizeId  = Guid.NewGuid().ToString(),
                    Category     = category,
                    ItemType     = 4,
                    ItemId       = route.Id,
                    ObjectId     = objectId,
                    CreateDate   = DateTime.Now,
                    CreateUserId = currentUserId,
                    IsHalf       = route.IsHalf
                };
                addAuthorizes.Add(entity);
            });
            return(await authorizeRepo.CreateAsync(addAuthorizes, dataBaseName));
        }