public async Task <SysModuleViewModel> SaveSysModule(SysModuleViewModel model)
        {
            int pnum = 0;

            if (model.ControllerName != null)
            {
                pnum = GetPurviewNum(model.ControllerName);
            }
            model.ControllerName = model.ControllerName == null ? model.ControllerName = "" : model.ControllerName;
            var entity = model.ToEntity();

            entity.Id          = SequenceQueue.NewIdString("");
            entity.CreateTime  = DateTime.Now;
            entity.Sort        = 0;
            entity.PurviewNum  = model.ControllerName == "" ? 0 : pnum + 1;
            entity.PurviewSum  = model.ControllerName == "" ? 0 : 2L << pnum;
            entity.Application = null;
            try
            {
                await _repository.AddAsync(entity);

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(model);
        }
        public CategoryViewModel SaveCategory(CategoryViewModel model)
        {
            var entity = model.ToEntity();

            entity.CategoryId = SequenceQueue.NewIdString("");
            entity.CreateDate = DateTime.Now;
            _repository.AddAsync(entity);
            _context.SaveChanges();
            return(model);
        }
Exemple #3
0
        public async Task <SysRoleViewModel> SaveSysRole(SysRoleViewModel model)
        {
            var entity = model.ToEntity();

            entity.Id         = SequenceQueue.NewIdString("");
            entity.RoleName   = model.Name;
            entity.CreateTime = DateTime.Now;
            entity.RoleType   = (int)model.RoleType;
            entity.IsDelete   = false;
            await _repository.AddAsync(entity);

            return(model);
        }
Exemple #4
0
        public async Task <SysApplicationViewModel> SaveSysApplication(SysApplicationViewModel model)
        {
            SysApplication entity = new SysApplication();

            entity.ApplicationName = model.ApplicationName;
            entity.ApplicationUrl  = model.ApplicationUrl;
            entity.CreateTime      = DateTime.Now;
            entity.Id = SequenceQueue.NewIdString("");
            await _repository.AddAsync(entity);

            await _context.SaveChangesAsync();

            model.Id         = entity.Id;
            model.CreateTime = entity.CreateTime;
            return(model);
        }
        public async Task <SysDepartmentViewModel> SaveSysDepartment(SysDepartmentViewModel model)
        {
            var entity = model.ToEntity();

            entity.DepartmentId   = SequenceQueue.NewIdString("");
            entity.State          = 0;
            entity.ParentId       = model.ParentId;
            entity.DepartmentName = model.DepartmentName;
            model.Id = entity.DepartmentId;

            await _repository.AddAsync(entity);

            await _context.SaveChangesAsync();

            return(model);
        }
Exemple #6
0
        public async Task SaveRoleModule(SysRoleModuleViewModel model)
        {
            _rolemoduleRepository.Delete(a => a.RoleId == model.RoleId);
            List <SysRoleModules> list = new List <SysRoleModules>();

            foreach (SysModuleBase moduleBase in model.ModuleBases)
            {
                list.Add(new SysRoleModules()
                {
                    ModuleId = SequenceQueue.NewIdString(""), PurviewSum = moduleBase.PurviewSum, ApplicationId = "", RoleId = model.RoleId, ControllerName = moduleBase.ControllerName
                });
            }
            await _rolemoduleRepository.AddRangeAsync(list);

            _context.SaveChanges();
            _signal.SignalToken(model.RoleId);//设置过期
        }
Exemple #7
0
        public async Task <IActionResult> Create(SysUsersCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var entity = new SysUsers();
                entity.Id                   = SequenceQueue.NewIdString("");
                entity.UserName             = model.Username;
                entity.FullName             = model.FullName;
                entity.IsLock               = false;
                entity.Email                = model.Email;
                entity.EmailConfirmed       = false;
                entity.TwoFactorEnabled     = false;
                entity.PhoneNumber          = model.Tel;
                entity.PhoneNumberConfirmed = false;
                entity.LockoutEnabled       = true;
                entity.CreateTime           = DateTime.Now;
                try
                {
                    entity.Roles.Add(new SysUserRole()
                    {
                        UserId = entity.Id
                    });
                    var result = await _userManager.CreateAsync(entity, model.Password);

                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Description);
                    }
                    if (!ModelState.IsValid)
                    {
                        return(View());
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }


                return(Redirect("/SiteManager/SysUsers/Index"));
            }

            return(View());
        }