public User AddUser(string username, string description, BaseStatuses enabled) { using (TransactionScope scope = new TransactionScope()) { User entity = new User { Username = username, Status = enabled, Password = StringHelper.EncodePassword(username, "123456"), Id = this.PrivilegeContextProvider.GetRepository().Use <User>().GetSequenceId(), CreateTime = DateTime.Now, Description = description }; var reps = this.PrivilegeContextProvider.GetRepository(); reps.Use <User>().Add(entity); reps.SaveChanges(); scope.Complete(); return(entity); } }
public Role AddRole(string name, BaseStatuses status, string description, int? departmentId = new int?()) { Role entity; using (TransactionScope scope = new TransactionScope()) { using (var reps = PrivilegeContextProvider.GetRepository()) { entity = new Role { Name = name, DepartmentId = departmentId, Status = status, Id = reps.Use<Role>().GetSequenceId(), Description = description }; entity = reps.Use<Role>().Add(entity); reps.SaveChanges(); } scope.Complete(); } return entity; }
public Role AddRole(string name, BaseStatuses status, string description, int?departmentId = new int?()) { Role entity; using (TransactionScope scope = new TransactionScope()) { using (var reps = PrivilegeContextProvider.GetRepository()) { entity = new Role { Name = name, DepartmentId = departmentId, Status = status, Id = reps.Use <Role>().GetSequenceId(), Description = description }; entity = reps.Use <Role>().Add(entity); reps.SaveChanges(); } scope.Complete(); } return(entity); }
public User AddUser(string username, string description, BaseStatuses enabled) { using (TransactionScope scope = new TransactionScope()) { User entity = new User { Username = username, Status = enabled, Password = StringHelper.EncodePassword(username, "123456"), Id = this.PrivilegeContextProvider.GetRepository().Use<User>().GetSequenceId(), CreateTime = DateTime.Now, Description = description }; var reps = this.PrivilegeContextProvider.GetRepository(); reps.Use<User>().Add(entity); reps.SaveChanges(); scope.Complete(); return entity; } }