示例#1
0
        public void Create(UserModel model)
        {
            var user = mapper.ToEntity(model);

            dataContext.Users.Add(user);

            user.Roles = model.Roles?.Select(e =>
            {
                return(new UserRole()
                {
                    RoleId = e.RoleId
                });
            }).ToList();

            dataContext.SaveChanges();
            model.Id = user.Id;
        }