예제 #1
0
        public async Task <IActionResult> Post([FromBody] CreateRoleInputModel inputModel)
        {
            if (await _context.Roles.AnyAsync(t => t.Name == inputModel.Name))
            {
                return(BadRequest("账号已存在"));
            }

            var role = new DncRole
            {
                Name        = inputModel.Name,
                Description = inputModel.Description,
                status      = inputModel.status,
            };

            await _context.Roles.AddAsync(role);

            await _context.SaveChangesAsync();

            return(Ok());
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] CreateUserInputModel inputModel)
        {
            if (await _context.Users.AnyAsync(t => t.Account == inputModel.Account))
            {
                return(BadRequest("账号已存在"));
            }

            var dncUser = new DncUser
            {
                Account  = inputModel.Account,
                Password = inputModel.Password,
                NiName   = inputModel.NiName,
                Status   = inputModel.Status,
                Remark   = inputModel.Remark
            };

            await _context.Users.AddAsync(dncUser);

            await _context.SaveChangesAsync();

            return(Ok());
        }